4 Replies Latest reply on Jun 2, 2009 3:01 PM by Nick Belaevski

    rich:datable don't work when bean have a char based id with

    igor regis Newbie

      Hi,

      I use a Bean with an id that is a String with size 6 (it's a char(6) at database), when this id is filled with less then 6 characters the rich datatable component generate a ajax request that doesn't work because it uses the bean id value as row id.

      That's an example:

      @Entity
      @Table(name = "ti_oj_nro")
      public class ObjectInteraction implements java.io.Serializable {
      
       private String objId;
       private String nameObj;
      
       @Id
       @Column(name = "CD_TIP_OBJ_INRO", unique = true, nullable = false, columnDefinition = "char(6)", length = 6)
       @NotNull
       @Length(max = 6)
       public String getobjId() {
       return this.objId;
       }
      
       public void setobjId(String objId) {
       this.objId = objId;
       }
      
       @Column(name = "NM_TIP_OBJ_INRO", nullable = false, columnDefinition = "char(30)", length = 30)
       @NotNull
       @Length(max = 30)
       public String getnameObj() {
       return this.nameObj;
       }
      
       public void setnameObj(String nameObj) {
       this.nameObj = nameObj;
       }
      
      }


      xhtml page code fragment:

       <rich:dataTable id="objInteractionList"
       var="_objInteraction"
       rows="10"
       value="#{objInteractionList.dataModel}"
       rendered="#{objInteractionList.dataModel.rowAvailable}"
       reRender="datascroller">
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Id"/>
       </f:facet>
       <h:outputText value="#{_objInteraction['objId']}"/>
       </rich:column>
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Name"/>
       </f:facet>
       <h:outputText value="#{_objInteraction['nameObj']}"/>
       </rich:column>
      
       <rich:column id="action" styleClass="action">
       <f:facet name="header">action</f:facet>
       <a4j:commandLink id="btEditar" actionListener="#{objInteractionHome.loadobjInteractionListener}" action="editarobjInteraction" value="Edit">
       <f:param id="paramEditar" name="objInteractionobjId"
       value="#{_objInteraction.objId}"/>
       </a4j:commandLink>
       </rich:column>
       <f:facet name="footer">
       <rich:datascroller id="datascroller" rendered="#{objInteractionList.dataModel.rowAvailable}"/>
       </f:facet>
       </rich:dataTable>
      


      This code will generate a tag to render a link that execute an Ajax request, for the case when I have the char id with less the 6 characters, this will be generated:

      <a onclick="A4J.AJAX.Submit('_viewRoot','mainPage:j_id165',event,{'similarityGroupingId':'mainPage:j_id165:objInteractionList:1 :btEditar','parameters':{'mainPage:j_id165:objInteractionList:1 :btEditar':'mainPage:j_id165:objInteractionList:1 :btEditar','objInteractionCodigoobjInteraction':'1 '} ,'actionUrl':'/mySystem/index.jsf'} );return false;" name="mainPage:j_id165:objInteractionList:1 :btEditar" id="mainPage:j_id165:objInteractionList:1 :btEditar" href="#">Edit</a>


      Observe that at this case the Id is equal to 1 and we get a space right after the '1' number wherever the id is used, even if I use trim on my bean property accessors.

      Anyone have a clue if it's a limitation, or a bug? Should I do something different?

      Regards,
      Igor