3 Replies Latest reply on May 14, 2010 5:27 PM by kmranganathan

    custom home with required=true...

    kmranganathan
      Hi,
      I want to build a custom page - just to maintain a list of master titles - page will have one text field, add button. When add is clicked, title will be added and shown in the same page in a list box. Besides the list box, a Delete button will be provided which when clicked will delete the entity.

      The problem I face is: The text is mandatory while adding - so,I have a required=true against it. Now, when 'Delete' is clicked without entering text, it throws an error and delete is not invoked. How do I handle this?

      Thanks,
      Ranga.
        • 1. Re: custom home with required=true...
          sean.tozer

          Depending on what kind of button it is, you could try using immediate="true" or ajaxSingle="true" on it, so as to ignore the rest of the form inputs when it fires.

          • 2. Re: custom home with required=true...
            thokuest

            You can handle it by placing input text box / add-button and list box / delete-button in separate forms. This is a simple (and incomplete) example:


            <h:form id="creationForm">
                <!-- input field goes here -->
                <a4j:commandButton action="#{bean.action}" value="Create" reRender="deletionFormPanel" />
            </h:form>
            
            <a4j:outputPanel id="deletionFormPanel">
                <h:form id="deletionForm">
                    <!-- list box and delete-button goes here -->
                </h:form>
            </a4j:outputPanel>



            I don't recommend the solution with immediate="true" / ajaxSingle="true" because it implies other problems.


            Hope that helps!

            • 3. Re: custom home with required=true...
              kmranganathan

              Hi,
              Using the 2 Forms is working.



              Thanks very much,
              Ranga.