2 Replies Latest reply on Apr 3, 2009 5:58 AM by ilya_shaikovsky

    inplaceSelect in dataTable problems

    timbooo

      hi there,

      i'm experiencing some problems with an inplace select component im my datatable (subtable).

      inplace select has a vector of users (myobject) as value.
      after i select a user in the last line, a new line is dynamically added to the datatable and the table gets rerendered.

      however, the inplaceSelect column always displays my defaultLabel.

      what am i doing wrong??

      any help appreciated.

      best regards
      tim.


      xhtml

      <rich:dataTable ...>
       [... header columns]
      
       <rich:subTable id="rightsSubTable" value="#{holderOfRights}"
       var="rightsHolder"
       onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
       <rich:column>
       <rich:inplaceSelect id="userValue"
       value="#{rightsHolder.user}"
       defaultLabel="#{res.showUser_rights_add}" listWidth="500"
       listHeight="250"
       showValueInView="true">
       <a4j:support event="onchange"
       actionListener="#{orgUnitBean.addUserRightsLine}"
       reRender="rightsHolderTable" requestDelay="100" />
       <f:selectItems id="selectOrgUnits"
       value="#{orgUnitBean.selectUsers}" />
       <f:converter converterId="UserConverter" />
       </rich:inplaceSelect>
       </rich:column>
      
       [...]
       </rich:subTable>
      </rich:subTable>
      


      selectItems value
      public LinkedList<SelectItem> getSelectUsers() {
       LinkedList<SelectItem> list = new LinkedList<SelectItem>();
       Iterator<User> it = getAllUsers().keySet().iterator();
       while (it.hasNext()) {
       User u = it.next();
       selectUsersTmp.add(new SelectItem(u, u.toString()));
       }
       return selectUsersTmp;
      }
      


      UserConverter
      public class UserConverter implements Converter {
      
       public UserConverter() {
       }
      
       public BaseBean getBean() {
       return (BaseBean) FacesContext.getCurrentInstance()
       .getExternalContext().getSessionMap().get("bean");
       }
      
       public Object getAsObject(FacesContext context, UIComponent component,
       String value) {
       if (value == null || (value.trim().length() == 0)) {
       return value;
       }
       User u = null;
       try {
       String uid = value.substring(value.indexOf("(") + 1, value
       .indexOf(")"));
       u = getBean().getAllUsers().get(uid);
       } catch (Exception e) {
       // TODO:
       }
       return u;
       }
      
       public String getAsString(FacesContext context, UIComponent component,
       Object value) {
       return value.toString();
       }
      
      }