2 Replies Latest reply on Jul 25, 2007 1:46 PM by sammy8306

    Validation and selectOneMenu question

    sammy8306

      I have two questions:

      1) It seems that my custom validator on a text input is not called when it is empty. Apparently this is a JSF issue (I'm using MyFaces 1.1.4), but maybe Seam offers a solution?

      2) I'm using a selectOneMenu to add items to a list (the list is updated using Ajax4JSF, using the onSubmit hook). I'm rerendering the list (a ui:repeat) and the selectOneMenu every time a new element is selected in the selectOneMenu. Now, I would like the value of the menu to be reset to the noSelectionLabel. I tried setting the value binding to a property that always returns null, and even tried returning NoSelectionConvertor.NOSELECTIONVALUE (or something like that :). But, the last selected item always remains selected... what can I do about this?

        • 1. Re: Validation and selectOneMenu question
          damianharvey

          1. Other than setting required="true" I don't think that there's much else that you can do.

          2. Are you reRendering your selectOneMenu after the ajax4jsf call?

          • 2. Re: Validation and selectOneMenu question
            sammy8306

            1. Well, that would be a solution (although it is semantically different from what I really want)

            2. The corresponding code:

            <a:region>
             <a:outputPanel id="<% !a_id %>">
             <a:repeat var="listvar" value="<% !binding %>">
             <h:outputText value="#{listvar} "/>
             <a:commandButton ajaxSingle="true" value="Delete" reRender="<% !a_id %>" action="#{<% !a_remove %>}"/>
             <br />
             </a:repeat>
             </a:outputPanel>
             <br />
             <s:decorate>
             <h:selectOneMenu id="<% !ident %>" value="#{dev.nulll}" valueChangeListener="#{<% !a_listener %>}">
             <s:selectItems var="field" label="#{field.toString}" value="#{<% <all-concept> type %>}" noSelectionLabel="Please select : " />
             <s:convertEntity/>
             <a:support event="onchange" reRender="<% !a_id %>" bypassUpdates="true" />
             </h:selectOneMenu>
             </s:decorate>
             </a:region><%
            

            (Never mind the weird <% %> holes in the XML, this is due to this being a template in generative setting, the gist of it is clear I think)

            All I know is that the a:repeat gets re-rendered fine, and it is in the same outputPanel as the selectOneMenu. I confirmed that the 'dev.nulll' method gets called when the rerender happens (so the actual value of the selectOneMenu is requested), it just isn't reflected in the page...

            Thanks,
            Sander