0

I am using Primefaces and JSF to develop this frontend. My issue is that one of my selectonemenus never sets its value binding, "selectedGroup", so the second dropdown is never populated. My backing bean is being called to "update" the second selectonemenu, but the listener of that ajax is not called, nor is selectedGroup ever set. This code is effectively identical to the Showcase for "Select". I even verified that the showcase code works from scratch (which i did not doubt), but fail to see how my situation is any different from that example.

Other stackoverflow questions on this topic indicate that something was left out, but none of those suggestions matched my issue.

I have two selectOneMenus, like so.

<h:form id="outerForm">

    <p:panel id="outerPanel">

        <p:panelGrid id="outerPanelGrid">
            <h:outputLabel for="groupSelection" value="Group: "/>
            <p:selectOneMenu id="groupSelection" value="#{myBean.selectedGroup}" >
                <p:ajax update="commandSelection"
                        listener="#{myBean.handleGroupSelection}" />
                <f:selectItem itemLabel="---Please Select Group---" itemValue=""/>
                <f:selectItems var="group" value="#{myBean.groups}"
                               itemLabel="#{group.name}" itemValue="#{group.name}" />
            </p:selectOneMenu>

            <h:outputLabel for="commandSelection" value="Command: "/>
            <p:selectOneMenu id="commandSelection" value="#{myBean.command}">
                <f:selectItems value="#{myBean.commandStringsList}"/>
            </p:selectOneMenu>
        </p:panelGrid>
     </p:panel>
</h:form>

This page is being displayed in the "center" portion of my layout template like so..

<ui:define id="content" name="content">
    <p:panel id="contentPanel" style="float:left; border:none">
        <ui:include src="#{anotherBean.currentView}.xhtml"/>
    </p:panel>
</ui:define>

The backing bean DOES use some data classes to contain some of the data which is populated, but I thought i was doing everything correct to map it into the view. For the most part, I am using Strings, though.

Does anyone see what I am missing? At the very least, is this xhtml valid?

I should also mention that this page was working before I created and used a template. Basically, I was rendering it in a tab of a tabview using ui:include in the body of index.xhtml. Though I did not notice initially, this page stopped working sometime after I incorporated the template (poor testing on my part, I know).

ThatsAMorais
  • 659
  • 8
  • 16
  • Just to clarify: your form id is outerForm. you havent nested forms, right? – Johny T Koshy Jan 10 '14 at 02:47
  • Correct, the ui:define exists in a ui:composition, and the template layout does not contain any forms, either. – ThatsAMorais Jan 10 '14 at 02:50
  • Go through http://stackoverflow.com/a/2120183/757071 and http://stackoverflow.com/a/16125396/757071, the points in the answer might help. – Johny T Koshy Jan 10 '14 at 03:01
  • Thanks, johny, I definitely see a few things in that list that may be applicable. Although, many of them I eliminated. There was one interesting one about , that I'd like to verify. The fact that I'm using a template may be playing a role. I'll have to verify that I am using h:. – ThatsAMorais Jan 10 '14 at 04:09
  • I would definitely like to mark an answer on this, but I just can't as I never solved it. My solution was to reset to a previous revision and slowly pull in my changes from a branch where I checked in all of the broken changes until I had everything I wanted. I managed not to pull-in whatever was wrong. Judging by what I did NOT pull in, I must have messed up my index.xhtml somehow, or the bean backing it. – ThatsAMorais Jan 10 '14 at 19:51

1 Answers1

0
<f:selectItems var="group" value="#{myBean.groups}"
    itemLabel="#{group.name}" itemValue="#{group.name}" />

you can't specify selectItems this way. translation has to be bidirectional. use a converter!

<f:selectItems var="group" value="#{myBean.groups}"
    itemLabel="#{group.name}" itemValue="#{group}" 
    converter="groupConverter"/>
Michele Mariotti
  • 7,372
  • 5
  • 41
  • 73
  • Only that OP doesn't want `#{group}`, he wants `#{group.name}`, which appears to be a `String`: No conversion necessary – kolossus Jan 10 '14 at 16:55
  • Correct, kolossus, group is a String. Even now, I never figured out what was happening with this after storing all of my most recent changes in a separate branch and resetting head, slowly adding back the changes I wanted. After doing that I managed to not re-encounter the issue. – ThatsAMorais Jan 10 '14 at 19:49
  • `#{myBean.selectedGroup}` is a String? (isn't `selectedGroupName` a better identifier?) – Michele Mariotti Jan 10 '14 at 20:26