1

I have a <p:selectOneMenu> where you choose a level; that is populated with a list and when one of these <f:selectItems> are clicked then with <p:ajax> I update my <p:selectManyMenu> with another list, with Entries. I want it to default select the first element in that list of entries and mark it, that is not what happens.

What does happen is that, it takes the old value saved in the attribute submittedValue and uses the value stored in that attribute, this does not exists in current list and therefor, it is not marked.

selectOneMenu

<p:selectOneMenu id="levelSelection" style="width:342px;text-align:left"
       panelStyle="width:180px"
       value="#{cc.attrs.agOptionObj.levelTemp}"
       onchange="onLevelSelectionChange(this), updateChild();"
       panelStyleClass="auto-close-panel"
       converter="lyngsoe.catellae.converter.LongOptionConverter"
       rendered="#{!cc.attrs.agOptionObj.hidePartitionSelection}">
           <f:selectItems
               value="#areaGroupSelection.getLevelsForHierarchy
                      (cc.attrs.agOptionObj,
                      cc.attrs.controller.model.periodSelectionOption,                        
                      cc.attrs.controller.reportName)}"
               var="levelOpt" 
               itemLabel="#{levelOpt.text}" 
               itemValue="#{levelOpt}"/>

           <p:ajax 
               update="levelEntries"
               listener="#{areaGroupSelection.levelChanged
                    (cc.attrs.agOptionObj,
                    cc.attrs.controller.model.periodSelectionOption)}"
               partialSubmit="true"/>
</p:selectOneMenu>

selectManyMenu

<p:selectManyMenu id="levelEntries"
        value="#{cc.attrs.agOptionObj.entriesTemp}"
        style="width:342px;text-align:left;height:150px"
        onchange="onEntriesSelectionChange(this);"
        converter="lyngsoe.catellae.converter.StringOptionConverter"
        rendered="#{!cc.attrs.hidePartitionSelection}"
        required="true"
        requiredMessage="#{msg['areaGroupSelection.areaError']}">
            <f:selectItems
               value="#{areaGroupSelection.getHierarchyNodesAtLevel
                         (cc.attrs.agOptionObj,
                         cc.attrs.controller.model.periodSelectionOption)}"
               var="entryOpt" itemLabel="#{entryOpt.text}" itemValue="#               
                           {entryOpt}"/>
</p:selectManyMenu>

I have read and tried the following links:

I am unsure if, what I am looking for is the use of one of these:

To clarify: I need to be able to choose from my <p:selectOneMenu> and then populate my <p:selectManyMenu> AND have the first element in <p:selectManyMenu>to be default selected.

If any further clarification is needed, please write - I will be monitoring this post like a hawk.

Community
  • 1
  • 1
Jesper
  • 119
  • 1
  • 3
  • 15
  • 1
    With those links, you mean to say that `` didn't work? – BalusC Jun 23 '15 at 11:51
  • Is there a similar in primefaces ? http://showcase.omnifaces.org/eventlisteners/ResetInputAjaxActionListener ? @BalusC : will double check – Jesper Jun 23 '15 at 11:54
  • @BalusC I tried it again , and this time it worked - at first I was experiencing some kind og gui glitch; can't reproduce it, so I do believe it is working. – Jesper Jun 25 '15 at 07:30

1 Answers1

2

This problem has the same grounds as already explained and answered here: How can I populate a text field using PrimeFaces AJAX after validation errors occur?

In your specific case, just use <p:ajax resetValues="true">. You only need to make sure that the <p:ajax update> covers the input components which need to be resetted, and that <p:ajax process> doesn't cover them.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555