0 Replies Latest reply on Sep 15, 2011 8:26 AM by jjmiller

    listShuttle error - component has invalid expression

    jjmiller

      I’m having a problem with the rich listShuttle component.  I’m getting the common “component...has invalid value expression” error that a lot of people seem to be getting.  I’ve been scouring the boards and it seems that, for most people, the problem lies with the converter.  I’ve been troubleshooting this for a couple hours now and can’t get it working, hoping someone can take a look at my code and see if I’m making a simple mistake.

       

      I do have a converter, and I have overwritten the equals and hashcode methods in my object.  I’ve also made that object Serializable (it extends BaseModel, which is Serializable).  All I'm trying to accomplish right now is to get it to print the contents of the two lists to the console to prove that it's working.  The lists are getting filled correctly, and show up on screen.  The error comes when I hit the "Save" button.  Also, the bean that contains the list is in session scope.

       

      Any help is appreciated, here’s my code:

       

       

      ColumnSequence object 

      import java.util.Date;
      
      public class ColumnSequence extends BaseModel
      {
          private static final long serialVersionUID = 1L;
          private int id;
          private String userId;
          private String pageId;
          private String pageName;
          private String tableId;
          private String tableName;
          private String columnId;
          private String columnName;
          private int columnOrder;
          private boolean visible;
      
          public ColumnSequence()
          {
          }        
          
          public ColumnSequence(int id, String user, String pageId, String pageName, String tableId, String tableName, 
                  String columnId, String columnName, int columnOrder, boolean visible, String lastUpdateUser, 
                  Date lastUpdateTimestamp, String creationUser, Date creationTimestamp)
          {
              super();
              this.id = id;
              this.userId = user;
              this.pageId = pageId;
              this.pageName = pageName;
              this.tableId = tableId;
              this.tableName = tableName;
              this.columnId = columnId;
              this.columnName = columnName;
              this.columnOrder = columnOrder;
              this.visible = visible;
              this.setLastUpdateUserId(lastUpdateUser);
              this.setLastUpdateTimestamp(lastUpdateTimestamp);
              this.setCreationUserId(creationUser);
              this.setCreationTimestamp(creationTimestamp);
              
          }
          public String toString()
          {
              return id + "," + userId + "," + pageId + "," + pageName + "," + tableId + "," + tableName + "," + columnId + "," 
                      + columnName + "," + columnOrder + "," + visible + "," + getLastUpdateUserId() + ","
                      +  getLastUpdateTimestamp() + "," + getCreationUserId() + "," + getCreationTimestamp();
          }    
      
          //removed getters/setters
          
          @Override
          public boolean equals(Object o)
          {
              if (o == this) return true;
              if (!(o instanceof ColumnSequence)) return false;
              ColumnSequence that = (ColumnSequence) o;
              if (this.id == that.id 
                      && this.userId == that.userId
                      && this.pageId == that.pageId
                      && this.pageName == that.pageName
                      && this.tableId == that.tableId
                      && this.tableName == that.tableName
                      && this.columnId == that.columnId
                      && this.columnName == that.columnName
                      && this.columnOrder == that.columnOrder
                      && this.visible == that.visible
                      && this.getLastUpdateUserId() == that.getLastUpdateUserId()
                      && this.getLastUpdateTimestamp() == that.getLastUpdateTimestamp()
                      && this.getCreationUserId() == that.getCreationUserId()
                      && this.getCreationTimestamp() == that.getCreationTimestamp())
              {
                  return true;
              } else
              {
                  return false;
              }
          }
       
          @Override
          public int hashCode()
          {
              int result = 17;
              result = 37 * result + id;
              result = 37 * result + userId.hashCode();
              result = 37 * result + pageId.hashCode();
              result = 37 * result + pageName.hashCode();
              result = 37 * result + tableId.hashCode();
              result = 37 * result + columnId.hashCode();
              result = 37 * result + columnOrder;
              result = 37 * result + (visible ? 0 : 1);
              result = 37 * result + getCreationUserId().hashCode();
              
              return result;
          }
      }
      

       

       

       

      ColumnSequenceConverter

      import java.text.DateFormat;
      import java.text.ParseException;
      import java.text.SimpleDateFormat;
      import java.util.Date;
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import com.enterprise.webframework.util.Log;
      import com.model.ColumnSequence;
      public class ColumnSequenceConverter implements javax.faces.convert.Converter
      {
          private Date parseStringToDate(String input)
          {
              Date result = null;
              DateFormat formatter;
              formatter = new SimpleDateFormat("yyyy-MM-dd");
              try
              {
                  result = (Date) formatter.parse(input);
              } catch (ParseException e)
              {
                  e.printStackTrace();
              }
              return result;
          }
          public Object getAsObject(FacesContext context, UIComponent component,
                  String value)
          {
              
              if ( null != value )
              {            
                  Log.logDebug(this, "value: " + value);
                  
                  String[] columnIn = value.split(",");            
                  
                  int id = Integer.parseInt(columnIn[0]);
                  String user = columnIn[1];
                  String pageId = columnIn[2];
                  String pageName = columnIn[3];
                  String tableId = columnIn[4];
                  String tableName = columnIn[5];
                  String columnId = columnIn[6];
                  String columnName = columnIn[7];
                  int columnOrder = Integer.parseInt(columnIn[8]);
                  boolean visible = Boolean.parseBoolean(columnIn[9]);
                  String lastUpdateUser = columnIn[10];
                  Date lastUpdateTimestamp = parseStringToDate(columnIn[11]);
                  String creationUser = columnIn[12];
                  Date creationTimeStamp = parseStringToDate(columnIn[13]);
                  
                  
                  ColumnSequence column = new ColumnSequence(id, user, pageId, pageName, tableId, tableName,
                          columnId, columnName, columnOrder, visible, lastUpdateUser,
                          lastUpdateTimestamp, creationUser, creationTimeStamp);
                  
                  Log.logDebug(this, "toString(): " + column.toString());
                  
                  return column;
                  
              } else
              {
                  Log.logError(this, "value == null");
                  return new ColumnSequence();
              }
          }
          public String getAsString(FacesContext arg0, UIComponent arg1, Object value)
          {
              if ( !(value == null) )
              {
                  return value.toString();            
              } else
              {
                  return "";
              }
          }
      }
      

       

       

      My xhtml

      <rich:listShuttle sourceValue="#{columnSequenceBean.hiddenColumns}"
              targetValue="#{columnSequenceBean.visibleColumns}"
              var="items"
              sourceCaptionLabel="Hidden Columns"
              targetCaptionLabel="Visible Columns"
              converter="ColumnSequenceConverter">
          <rich:column>
              <h:outputText value="#{items.columnName}" />
          </rich:column>
      </rich:listShuttle>
       <a4j:commandButton value="save" action="#{classCodeController.saveButton}" />
      

       

       

       

      saveButton method in my controller class

      private void saveButton()
      {
          Log.logDebug(this, "Visible: ");
          for (ColumnSequence visible : columnSequenceBean.getVisibleColumns())
          {
              Log.logDebug(this, visible.toString());
          }
          
          Log.logDebug(this, "Hidden: ");
          for (ColumnSequence hidden : columnSequenceBean.getHiddenColumns())
          {
              Log.logDebug(this, hidden.toString());
          }
      }