[jboss-user] [JBoss Seam] - Object sent to equals() as parameter is null!

fmars do-not-reply at jboss.com
Fri Jul 20 13:18:57 EDT 2007


Hello,

I have an entity bean "CancerType" and a SFSB(long running) "MethSearch" and there is a "search.xhtml".

One of the search fields in "search.xhtml" is a selectOneMenu, in which all CancerTypes are listed. The selected one is set to "cancerType" variable in MethSearch bean. MethSearch bean has a method "find()", which is called from search.xhtml after a CancerType in selectOneMenu selected.

Problem: Before Seam the Method "find" calls, the overriden method "equals(Object otherCancerType)" in CancerType Entity is called, but the parameter "otherCancerType" is null. And i need to find why?

here some codes: first CancerType Entity
@Entity
  | public class CancerType implements java.io.Serializable {
  | // id and some string variables
  | @Override
  |     public boolean equals(Object otherCancerType) {
  |         if(this.id == ((CancerType)otherCancerType).getId())
  |             return true;
  |         return this.name.equals(((CancerType)otherCancerType).getName());
  |     }
  | }
MethSearch SFSB:
@Stateful
  | @Name("methsearch")
  | public class MethSearch implements IMethSearch{
  |     @PersistenceContext(type=PersistenceContextType.EXTENDED)
  |     private EntityManager entityManager;
  | .....
  | @Begin
  |     public void find() {
  |         Criteria criteria = ....
  | }
  | 

search.xthml:
<h:outputLabel for="cancerTypeid">Cancer type:</h:outputLabel>
  |     <h:selectOneMenu id="cancerTypeid" value="#{methsearch.cancerType}">
  |      <s:selectItems value="#{cancerTypeDAO.getAll()}" var="cancerType" label="#{cancerType.name}"
  |                                 noSelectionLabel="Please Select..."/>
  |       <s:convertEntity />
  |     </h:selectOneMenu>
  | ....
  | <h:commandButton value="Find" action="#{methsearch.find()}" />
  | 

and pages.xml:
<page view-id="/search.xhtml">
  |         <navigation from-action="#{methsearch.find()}">
  |             <end-conversation/>
  |             <redirect/>
  |         </navigation>
  |     </page>

Thank you in advance :)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066287#4066287

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4066287



More information about the jboss-user mailing list