10 Replies Latest reply on Nov 20, 2008 4:25 AM by Ilya Shaikovsky

    listShuttle values are not resetting......

    martin anderson Newbie

      Hi i am new to this richfaces and i am implementing listShuttle to choose some values but i have a peculiar problem since if user want to cancel all the changes in the page with cancel button all the fields being reset to original values except listshuttle can anybody help me to reset the values using listShuttle..... plzzzzz :'(

      thanks in advance....


        • 2. Re: listShuttle values are not resetting......
          martin anderson Newbie


          <?xml version="1.0" encoding="ISO-8859-1" ?>
           <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
           xmlns:ui="http://java.sun.com/jsf/facelets" version="2.0">
           function reset(){
           document.getElementById('custDetailsEditFrm:ext_timings')= #{custDetailsEditMBean.newCutOffs};
           <fieldset class="panel_fieldset"><legend
           class="panel_legend"> Basic Details</legend>
           <div style="height:500px;" class="panel-container"><f:view>
           <a4j:form id="custDetailsEditFrm">
           <table width="90%" cellpadding="5" cellspacing="5">
           <td><h:outputLabel value="Name" style="font-weight:bold" for="custName" /><em style="color:red">*</em></td>
           <td><h:inputText id="custName" value="#{custDetailsEditMBean.name}" style="width:250px;"/></td>
           <td><h:outputLabel style="font-weight:bold" value="Purge Days" for="purgeDys" /></td>
           <td><rich:inputNumberSpinner enableManualInput="false"
           id="purgeDys" value="#{custDetailsEditMBean.purgeDays}"></rich:inputNumberSpinner>
           <td><h:outputLabel style="font-weight:bold" value="Comment" for="comment" /></td>
           <td><h:inputTextarea id="comment" value="#{custDetailsEditMBean.comment}" style="width:250px;"
           rows="4" /></td>
           <td align="left"><h:selectOneRadio id="status" style="font-weight:bold" layout="pageDirection"
           <f:selectItem itemLabel="Active" itemValue="Active" />
           <f:selectItem itemLabel="Inactive" itemValue="Inactive" />
           <td colspan="4" align="center"><rich:panel
           header="Extraction Time">
           <rich:listShuttle id="ext_timings" orderControlsVisible="false"
           targetValue="#{custDetailsEditMBean.newCutOffs}" var="cutOff"
           listHeight="300" listWidth="300"
           sourceCaptionLabel="Available Times"
           targetCaptionLabel="Selected Times">
           <h:outputText value="#{cutOff}:00"></h:outputText>
           <tr align="center">
           <td colspan="4"><a4j:commandButton
           reRender="treeForm:customerTree" accesskey="S"
           onmouseout="goDim(this.form.name,this.name)" style="width:80px"
           styleClass="visionBtn" id="saveCustInfo" value="Save"
           <f:param name="saveRequest" value="true" />
           <rich:spacer width="3px;"/>
           <input type="button" id="cancel" class="visionBtn" value="Cancel" onclick="if (!confirm('Are you sure you want to cancel any unsaved changes')) return false; reset();" style="width:80px"/>

          here in the bold i am trying to reset the field in target value when the user presses reset value every other field is getting resetted except listShuttle ... plzzzz help me in this regard...

          thanks in advance


          • 3. Re: listShuttle values are not resetting......
            martin anderson Newbie

            Hi sorry i forgot to tell u that i need to reset targetValue as well as the sourceValue.....with the previous values

            • 4. Re: listShuttle values are not resetting......
              Ilya Shaikovsky Master

              such client side reset not implemented in LS component. So you should use immediate a4j:commandButton and reset the values on server side.

              • 5. Re: listShuttle values are not resetting......
                martin anderson Newbie


                thanks for the early reply i just wanted to know atleast how to access this targetValue object so that i will make it to some default value when user clicks reset button atleast with the help of javascript. But i am no way finding it how to achieve this.

                I think you know it better than anyone as you are the one who has designed this listShuttle(great one!!!) component :). Eagerly waiting for your response..

                thanks in advance......


                • 6. Re: listShuttle values are not resetting......
                  Ilya Shaikovsky Master

                  you have only source list filled by defult? Or there are both lists could be not empty?

                  • 7. Re: listShuttle values are not resetting......
                    martin anderson Newbie

                    i will be setting some default value in target list(which i will get it from bean) and once the user click the reset button i will restore that bean value.

                    my actual problem is how i suppose to get the targetValue using javascript because i have implemented listShuttle at 4 places.

                    If i can get that using javascript, it will make my job easy...

                    something like this....

                    document.getElementById('custDetailsEditFrm:ext_timings')= '#{custDetailsEditMBean.newCutOffs}';

                    but i don't get how to achieve the targetSource cell id or value to replace with what i already have in bean..


                    • 8. Re: listShuttle values are not resetting......
                      Nick Belaevski Master


                      There's no single input holding component's value . When user moves items between lists component script reorders internal inputs. These inputs can be identified easily - their name is equal to shuttle client id.

                      In principle, you can try to restore component to previous data by saving innerHTML property of listShuttle HTML element when the component is first rendered and then apply it on reset() however that is likely to break JavaScript object state.

                      I've created an RFC for this feature: https://jira.jboss.org/jira/browse/RF-4991

                      • 9. Re: listShuttle values are not resetting......
                        martin anderson Newbie

                        hi once again

                        i have worked around and got the solution as i did what ilya has adviced now i have one more problem with this listShuttle i need to sort in ascending order whenever user moves the value from source to target or vice versa and i found there is no button to do that it will be simple if i just drag and drop in whatever position i want (which i can't because i cannot sort as i can't access any target or source value using javascript)

                        please help me regarding this issue..

                        I've created an RFC for this feature: https://jira.jboss.org/jira/browse/RF-4991

                        i did't understand what i need to do........there as it is not allowing to post any comments or attach some files to it......


                        • 10. Re: listShuttle values are not resetting......
                          Ilya Shaikovsky Master


                          i did't understand what i need to do.......

                          Just vote for this feature in jira. Also you could add yourself to watchers to be updated after the issue resolved or commented.

                          about sorting.. This also not available on client side.
                          you could use onlistchanged event using a4j:support and resort the lists as you need via ajax.

                          B.t.w. there is an RFC in jira which tells about js API to allow client side moving to some concrete positions but it still not palnned to nearest releases.