0 Replies Latest reply on Nov 24, 2008 11:23 PM by Val Sw

    Please help problem comparing hash code of entity, need to click link twice

    Val Sw Expert
      I am trying to pass hashcode from xhtml page which needs to be compared with entity hashcode. I have a commandLink which adds a row on the UI.

      Issue is on clicking commandLink first time page refreshes but row is not added because the hashcode is not equal.

      But when I click the link again it works fine and row is added ...

      PLEASE help what is weird in the code and how can I rectify it...

      <h:commandLink action="#{projectHome.addTreatmentLink}" 
                value="Add treatments">
           <f:param name="re_hashcode" value="#{info.hashCode()}"/>                                                 
      </h:commandLink>     

      public String addTreatmentLink(){
           javax.faces.context.FacesContext facesContext = (new org.jboss.seam.faces.FacesContext()).getContext();
           javax.servlet.http.HttpServletRequest hsr=(javax.servlet.http.HttpServletRequest)facesContext.getCurrentInstance().getExternalContext().getRequest();
           String reagentHashcode=hsr.getParameter("re_hashcode");
           
           for(int i=0;i<reagent.length;i++){
                   if(reagent[i].hashCode()==Integer.parseInt(reagentHashcode)){
                          reagent[i].getTreatment().add(new Treatment());
                          break;
                   }
           }
           return "";     
      }