10 Replies Latest reply on Mar 11, 2009 10:49 AM by ilya_shaikovsky

    listshuttle is throwing has invalid value expression

    prakhar211

      Hi,

      On the screen there are various fields,one dropdown & one listShuttle. When i change the value in this dropdown that time i am filling the source value of list Shuttle & i am reRendering it.

      Till this point it works fine. but when i submit the form than i got the error message

      rich:listShuttle is surrounded by a4j:region

      component rich:listShuttle has invalid value expression.

      at present the value in sourceValue & targetValue are getting filled via action.attribute but i have also tried it by using VO with equals & hashcode implemented.

        • 1. Re: listshuttle is throwing has invalid value expression
          nbelaevski

          Hello,

          Do you use request-scoped bean to hold value?

          • 2. Re: listshuttle is throwing has invalid value expression
            prakhar211

            Bean in not in any scope.My action class is in conversation scope. Currently source & target value of listshuttle are getting filled through the class level variables defined in action class.
            Sample code

            Action class(in Conversation scope) contains:

            List sourceReport = new ArrayList;
            List targetReport = new ArrayList;

            xhtml snippet
            <a4j:region>
            <rich:listshuttle sourceValue="action.sourceReport" targetValue="action.targetReport"......etc>
            </a4j:region>
            some other fields of xhtml mapped to VO or bean
            <h:inputText value="VO.name">
            <h:inputText value="VO.address">

            • 3. Re: listshuttle is throwing has invalid value expression
              nbelaevski

              Please post full page and bean code.

              • 4. Re: listshuttle is throwing has invalid value expression
                prakhar211

                One point to note: If we click edit & than try saving same record than in this case it is working but we want to add new record than validation message for listshuttle started coming.

                Xhtml code

                <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:c="http://java.sun.com/jstl/core"
                xmlns:s="http://jboss.com/products/seam/taglib">


                function resetField(){
                $('policyListNameFrm:policyCode').disabled=false;
                $('policyListNameFrm:policyCode').value='';
                $('policyListNameFrm:listName').value='';
                $('policyListNameFrm:listPurpose').selectedIndex=0;
                $('policyListNameFrm:listType').selectedIndex=0;
                $('policyListNameFrm:source').selectedIndex=0;
                $('policyListNameFrm:description').value='';
                $('policyListNameFrm:btnAdd').value='Add';
                $('policyListNameFrm:source').disabled=false;
                }







                Policy Information

                <rich:simpleTogglePanel switchType="client" label="Add Policy" width="99.6%" id="addpolicyPanel">
                <a4j:region id="policyNameRegion">
                <h:form id="policyListNameFrm" style="margin:0;padding:0;">
                <h:inputHidden value="#{policyListName.policyCode}" id="hdnpolicyCode"></h:inputHidden>
                <h:panelGrid columns="2" border="0" cellspacing="0" id="listNamesPanel" width="90%">
                <h:panelGrid columns="2" border="0" cellspacing="3">
                <h:outputLabel value="Policy Code" />
                <h:panelGrid columns="3" border="0" cellspacing="0" cellpadding="0">
                <h:inputText id="policyCode" value="#{policyListNameVO.policyCode}" siAB="50" styleClass="TextBox" maxlength="50"
                onblur="$('policyListNameFrm:policyCode').value=$('policyListNameFrm:policyCode').value.toUpperCase();">
                <s:validate />
                </h:inputText>
                <rich:spacer width="3px" />
                <h:outputLabel value="*" style="color:red" />
                </h:panelGrid>
                <h:outputLabel value="Policy Name" />
                <h:panelGrid columns="3" border="0" cellspacing="0" cellpadding="0">
                <h:inputText id="listName" value="#{policyListNameVO.name}" siAB="50" styleClass="TextBox" maxlength="50" />
                <rich:spacer width="3px" />
                <h:outputLabel value="*" style="color:red" />
                </h:panelGrid>
                <h:outputLabel value="Policy Purpose" />
                <h:panelGrid columns="3" border="0" cellspacing="0" cellpadding="0">
                <h:selectOneMenu value="#{policyListNameVO.purpose}" id="listPurpose" style="width:201px">
                <f:selectItem itemValue="-1" itemLabel="Select" />
                <f:selectItems value="#{purposeList}" />
                </h:selectOneMenu>
                <rich:spacer width="3px" />
                <h:outputLabel value="*" style="color:red" />
                </h:panelGrid>
                <h:outputLabel value="Description" />
                <h:inputTextarea value="#{policyListNameVO.description}" id="description" cols="50" rows="4" styleClass="TextBoxA" maxlength="150" />
                </h:panelGrid>
                <h:panelGrid columns="2" border="0" cellspacing="3">
                <h:outputLabel value="Policy Type" />
                <h:panelGrid columns="3" border="0" cellspacing="0" cellpadding="0">
                <h:selectOneMenu value="#{policyListNameVO.type}" id="listType" style="width:201px">
                <f:selectItem itemValue="-1" itemLabel="Select" />
                <f:selectItems value="#{listTypes}" />
                </h:selectOneMenu>
                <rich:spacer width="3px" />
                <h:outputLabel value="*" style="color:red" />
                </h:panelGrid>

                <h:outputLabel value="Source" />

                <h:selectOneMenu value="#{policyListNameVO.source}" id="source" style="width:200px" valueChangeListener="#{policyAction.selectedParentpolicy}">
                <f:selectItem itemValue="-1" itemLabel="Select" />
                <f:selectItems value="#{sourceCombo}" />
                <a4j:support event="onchange" onchange="AB.expandTogglePanel('policyListNameFrm:parentpolicyTogglePanel');"
                reRender="policyListNameFrm:parentpolicyCode" ajaxSingle="true" status="pb_status" >
                </a4j:support>
                </h:selectOneMenu>
                <h:outputLabel value="Parent policy" />
                <a4j:region>
                <rich:simpleTogglePanel
                switchType="client"
                label="Multiple Parent policy"
                opened="#{policyListName.policyCode ne null}" id="parentpolicyTogglePanel">

                <rich:listShuttle
                id="parentpolicyCode"
                sourceValue="#{policyAction.sourcepolicys}"
                targetValue="#{policyAction.targetpolicys}"
                var="item"
                listsHeight="170"
                sourceListWidth="150"
                targetListWidth="150"
                sourceCaptionLabel="Available Values"
                targetCaptionLabel="Selected Values"
                converter="#{ItemConverter}"
                fastOrderControlsVisible="false"
                orderControlsVisible="false">
                <rich:column>
                <h:outputText value="#{item.label}"></h:outputText>
                </rich:column>
                </rich:listShuttle>
                </rich:simpleTogglePanel>
                </a4j:region>
                </h:panelGrid>
                </h:panelGrid>
                <rich:separator height="1px" />
                <h:panelGrid columns="1" width="100%">
                <h:panelGroup style="float: right">
                <a4j:commandButton id="btnAdd" value="Add" action="#{policyAction.savepolicy()}" styleClass="ButtonStyleLink"
                reRender="policyError,policyABNamesTable,policyABNamesTableScroller,policyListNameFrm:parentpolicyCode,parentpolicyTogglePanel,parentpolicyCode" data="# {facesContext.maximumSeverity.ordinal ge 2}"
                oncomplete="if(data == false) {
                resetField();}" status="pb_status" limitToList="true"/>
                <rich:spacer width="3" />
                <a4j:commandButton id="cancelButton" value="Cancel" styleClass="ButtonStyleLink" action="#{policyAction.clearListShuttle()}"
                oncomplete="resetField();$('policyError').innerHTML='';" reRender="parentpolicyTogglePanel,parentpolicyCode"/>
                </h:panelGroup>
                </h:panelGrid>
                <h:inputHidden value="#{policyListName.operationStatus}" id="hdnoperationStatus" />
                </h:form>
                </a4j:region>
                <rich:messages passedLabel="" id="policyError" infoLabelClass="infoclass" layout="list" style="vertical-align: top;">
                <f:facet name="errorMarker">
                <h:graphicImage value="images/error.gif" />
                </f:facet>
                <f:facet name="infoMarker">
                <h:graphicImage value="img/icon_success_sml.gif" />
                </f:facet>
                </rich:messages>
                </rich:simpleTogglePanel>
                <a4j:region id="policyABListNamesFrmRegion">
                <rich:panel width="100%">
                <f:facet name="header">
                <h:outputText value="policy List" />
                </f:facet>

                <h:form id="policyABListNamesFrm" style="margin:0;padding:0;">

                <a4j:jsFunction name="reRenderParentpolicy" reRender="policyListNameFrm:parentpolicyCode"/>
                <rich:datascroller id="policyABNamesTableScroller" align="right" for="policyABNamesTable" maxPages="5" width="100%" status="pb_status" pageIndexVar="currentPage" pagesVar="totalPages">
                <f:facet name="pages">
                #{currentPage}/#{totalPages}
                </f:facet>
                </rich:datascroller>
                <rich:dataTable value="#{policyListNames}" var="policy_" reRender="policyABNamesTableScroller" id="policyABNamesTable" width="100%" rows="#{dataTableVO.rowsCount}"
                sortMode="single" onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
                <rich:column width="1%" align="center">
                <f:facet name="header"></f:facet>
                <h:selectBooleanCheckbox value="#{policy_.selected}" disabled="#{policy_.type eq 'Static'}" >
                </h:selectBooleanCheckbox>
                </rich:column>
                <rich:column width="140px">
                <f:facet name="header">Action</f:facet>
                <a4j:commandLink action="#{policyAction.currentpolicy()}" ajaxSingle="true"
                onclick="AB.expandTogglePanel('policyListNameFrm:parentpolicyTogglePanel');"
                oncomplete="$('policyListNameFrm:btnAdd').value='Save';$('policyListNameFrm:policyCode').disabled='true';$('policyListNameFrm:hdnoperationStatus').value='edit';reRenderParentpolicy();"
                value="edit" reRender="addpolicyPanel,policyListNameFrm:listNamesPanel,refrestDetailsPanel, policyError,policyListNameFrm:parentpolicyCode" status="pb_status" limitToList="true">
                <s:conversationPropagation type="join" />
                </a4j:commandLink> /
                <a4j:commandLink action="#{policyAction.currentDeletepolicy()}" value="delete" id="dellink"
                oncomplete="javascript:Richfaces.showModalPanel('delPanel'); resetField();"
                reRender="addpolicyPanel,delPanel, policyError,policyListNameFrm:parentpolicyCode,parentpolicyTogglePanel,parentpolicyCode" status="pb_status" limitToList="true">
                <s:conversationPropagation type="join" />
                </a4j:commandLink> /
                </rich:column>



                </ui:composition>

                Item

                public class Item implements Serializable, Comparable, Comparator {

                /** The Constant serialVersionUID. */
                private static final long serialVersionUID = 1L;

                /** The value. */
                private String value;

                /** The label. */
                private String label;

                /** The display order. */
                private int displayOrder;

                /**
                * Instantiates a new list item.
                */
                public Item() {
                super();
                }

                /**
                * Instantiates a new list item.
                *
                * @param value the value
                */
                public Item(String value) {
                super();
                this.value = value;
                }

                /**
                * Instantiates a new list item.
                *
                * @param value the value
                * @param label the label
                */
                public Item(String value, String label) {
                super();
                this.value = value;
                this.label = label;
                }

                /**
                * Gets the value.
                *
                * @return the value
                */
                public String getValue() {
                return value;
                }

                /**
                * Sets the value.
                *
                * @param value the new value
                */
                public void setValue(String value) {
                this.value = value;
                }

                /**
                * Gets the label.
                *
                * @return the label
                */
                public String getLabel() {
                return label;
                }

                /**
                * Sets the label.
                *
                * @param label the new label
                */
                public void setLabel(String label) {
                this.label = label;
                }

                /**
                * @return the displayOrder
                */
                public int getDisplayOrder() {
                return displayOrder;
                }

                /**
                * @param displayOrder the displayOrder to set
                */
                public void setDisplayOrder(int displayOrder) {
                this.displayOrder = displayOrder;
                }

                /**
                * (non-Javadoc).
                *
                * @param Item the list item
                *
                * @return the int
                *
                * @see java.lang.Comparable#compareTo(java.lang.Object)
                */
                @Override
                public int compareTo(Item Item) {
                return this.getDisplayOrder() - Item.getDisplayOrder();
                }

                /**
                * (non-Javadoc).
                *
                * @param Item the list item
                * @param anotherItem the another list item
                *
                * @return the int
                *
                * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
                */
                @Override
                public int compare(Item Item, Item anotherItem) {
                return Item.getDisplayOrder() - anotherItem.getDisplayOrder();
                }

                /*
                * (non-Javadoc)
                *
                * @see java.lang.Object#hashCode()
                */
                @Override
                public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + displayOrder;
                result = prime * result + ((label == null) ? 0 : label.hashCode());
                result = prime * result + ((value == null) ? 0 : value.hashCode());
                return result;
                }

                /**
                * Equals.
                *
                * @param obj the obj
                *
                * @return true, if equals
                *
                * @see java.lang.Object#equals(java.lang.Object)
                */
                @Override
                public boolean equals(Object obj) {
                if (this == obj)
                return true;
                if (obj == null)
                return false;
                if (getClass() != obj.getClass())
                return false;
                final Item other = (Item) obj;
                if (label == null) {
                if (other.label != null)
                return false;
                } else if (!StringUtils.trimToEmpty(this.label).equals(StringUtils.trimToEmpty(other.label)))
                return false;
                if (value == null) {
                if (other.value != null)
                return false;
                } else if (!StringUtils.trimToEmpty(this.value).equals(StringUtils.trimToEmpty(other.value)))
                return false;
                return true;
                }

                /**
                * To string.
                *
                * @return the string
                *
                * @author
                */
                public String toString() {
                StringBuffer buffer = new StringBuffer();
                buffer.append("Item[");
                buffer.append("label = ").append(label);
                buffer.append(" value = ").append(value);
                buffer.append("]");
                return buffer.toString();
                }

                }

                Policy VO


                /**
                * The Class policyListNamesVO.
                */
                @Name("policyListNameVO")
                public class policyListNamesVO implements java.io.Serializable {

                /** The Constant serialVersionUID. */
                private static final long serialVersionUID = 1L;

                /** The policy code. */
                private String policyCode;

                /** The name. */
                private String name;

                /** The description. */
                private String description;

                /** The type. */
                private String type;

                /** The purpose. */
                private String purpose;

                /** The data source code. */
                private String source;

                /** The multiple values. */
                private List sourcepolicys = new ArrayList(1);

                /** The multiple values. */
                private List targetpolicys = new ArrayList(1);



                /**
                * Gets the source
                *
                * @return the source
                */
                public String getSource() {
                return source;
                }


                public void setDataSourceCode(String source) {
                this.source = source;
                }

                @Pattern(regex = "[A-Z0-9_]*", message = "policy Code Should only contain A-Z,0-9 or _")
                public String getpolicyCode() {
                return policyCode;
                }

                public void setpolicyCode(String policyCode) {
                this.policyCode = policyCode;
                }

                public String getName() {
                return name;
                }

                public void setName(String name) {
                this.name = name;
                }

                public String getDescription() {
                return description;
                }

                public void setDescription(String description) {
                this.description = description;
                }

                public String getType() {
                return type;
                }

                public void setType(String type) {
                this.type = type;
                }

                public String getPurpose() {
                return purpose;
                }

                public void setPurpose(String purpose) {
                this.purpose = purpose;
                }



                /**
                * @return the sourcepolicys
                */
                public List getSourcepolicys() {
                return sourcepolicys;
                }

                /**
                * @param sourcepolicys the sourcepolicys to set
                */
                public void setSourcepolicys(List sourcepolicys) {
                this.sourcepolicys = sourcepolicys;
                }

                /**
                * @return the targetpolicys
                */
                public List getTargetpolicys() {
                return targetpolicys;
                }

                /**
                * @param targetpolicys the targetpolicys to set
                */
                public void setTargetpolicys(List targetpolicys) {
                this.targetpolicys = targetpolicys;
                }



                /**
                * @return
                * @author
                */
                public String toString() {
                StringBuffer buffer = new StringBuffer();
                buffer.append("policyListNamesVO[");
                buffer.append("source = ").append(source);
                buffer.append(" description = ").append(description);
                buffer.append(" policyCode = ").append(policyCode);
                buffer.append(" name = ").append(name);
                buffer.append(" purpose = ").append(purpose);
                buffer.append(" type = ").append(type);
                buffer.append("]");
                return buffer.toString();
                }

                /*
                * (non-Javadoc)
                * @see java.lang.Object#hashCode()
                */
                @Override
                public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((source == null) ? 0 : source.hashCode());
                result = prime * result + ((description == null) ? 0 : description.hashCode());
                result = prime * result + ((policyCode == null) ? 0 : policyCode.hashCode());
                result = prime * result + ((name == null) ? 0 : name.hashCode());
                result = prime * result + ((purpose == null) ? 0 : purpose.hashCode());
                result = prime * result + ((sourcepolicys == null) ? 0 : sourcepolicys.hashCode());
                result = prime * result + ((targetpolicys == null) ? 0 : targetpolicys.hashCode());
                result = prime * result + ((type == null) ? 0 : type.hashCode());
                return result;
                }

                /*
                * (non-Javadoc)
                * @see java.lang.Object#equals(java.lang.Object)
                */
                @Override
                public boolean equals(Object obj) {
                if (this == obj)
                return true;
                if (obj == null)
                return false;
                if (getClass() != obj.getClass())
                return false;
                policyListNamesVO other = (policyListNamesVO) obj;
                if (source == null) {
                if (other.source != null)
                return false;
                } else if (!source.equals(other.source))
                return false;
                if (description == null) {
                if (other.description != null)
                return false;
                } else if (!description.equals(other.description))
                return false;
                if (policyCode == null) {
                if (other.policyCode != null)
                return false;
                } else if (!policyCode.equals(other.policyCode))
                return false;
                if (name == null) {
                if (other.name != null)
                return false;
                } else if (!name.equals(other.name))
                return false;
                if (purpose == null) {
                if (other.purpose != null)
                return false;
                } else if (!purpose.equals(other.purpose))
                return false;
                if (sourcepolicys == null) {
                if (other.sourcepolicys != null)
                return false;
                } else if (!sourcepolicys.equals(other.sourcepolicys))
                return false;
                if (targetpolicys == null) {
                if (other.targetpolicys != null)
                return false;
                } else if (!targetpolicys.equals(other.targetpolicys))
                return false;
                if (type == null) {
                if (other.type != null)
                return false;
                } else if (!type.equals(other.type))
                return false;
                return true;
                }



                }


                Action class

                @Name("policyAction")
                @Scope(ScopeType.CONVERSATION)
                public class policyAction extends BasePolicyBean {

                /** The Constant serialVersionUID. */
                private static final long serialVersionUID = 1L;


                /** The policy list names. */
                @DataModel(scope = ScopeType.PAGE)
                private List policyListNames;

                /** The policy list name. */
                @DataModelSelection("policyListNames")
                @Out(required = false)
                @In(create = true)
                private policyListNamesVO policyListNameVO;



                /** The multiple values. */
                private List sourcepolicys = new ArrayList(1);

                /** The multiple values. */
                private List targetpolicys = new ArrayList(1);

                • 5. Re: listshuttle is throwing has invalid value expression
                  ilya_shaikovsky

                  So just check with debug in your ItemConverter converter methods if the conversion results are ok.

                  • 6. Re: listshuttle is throwing has invalid value expression
                    prakhar211

                    I am using same ItemConverter for other listShuttles also which are part of different screen.There it is not giving any problem.

                    • 7. Re: listshuttle is throwing has invalid value expression
                      ilya_shaikovsky

                      could you please show the method policyAction.savepolicy()

                      • 8. Re: listshuttle is throwing has invalid value expression
                        prakhar211

                        policyAction.savePolicy is not at all called.Before that only i get this validation message for listShuttle.

                        Eventhan if you want to have a look at that method please reply i will post that.

                        • 9. Re: listshuttle is throwing has invalid value expression
                          prakhar211

                           

                          "prakhar211" wrote:
                          policyAction.savePolicy is not at all called.Before that only i get this validation message for listShuttle.

                          Eventhan if you want to have a look at that method, can you please reply i will post that.


                          • 10. Re: listshuttle is throwing has invalid value expression
                            ilya_shaikovsky

                            Please create runnable sample with source for us. Anyway in your case we still think that the problem is in converter. Post the sample with sources and we will check it on our side.