1 2 Previous Next 17 Replies Latest reply on Apr 5, 2007 7:02 AM by ilya_shaikovsky

    suggestionbox event triggers form submit, second setter pass

    shooali

      Hi,

      I have a problem using suggestionbox:
      when entering some thing into the inputtext bound to the suggestion box, the whole form is submitted (which is ok, since I did not define any region), the problem happens in a selectOneRadio component I have on the same page, that in the second call to it's vaue's property setter, a null is passed as parameter. I have no idea where it comes from, and it does not seem to pass through the validator defined there at all.
      If instead, I just put a a4j:support on the page, that triggers a full form submit, every thing works fine.

      Please find attached the page source.

      any help is most appreciated.

      Thanks,

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:jp="http://www.jenia.org/jsf/popup"
       xmlns:af="http://www.emc.com/ajax/jsf"
       xmlns:t="http://myfaces.apache.org/tomahawk"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich">
      
      
      <body>
      
       <ui:composition>
       <h:form id="myform">
       <c:set var="pageBean" value="#{policyEditingWizardStageAddCustomConstraintBean}"/>
      
       <h:selectOneRadio id="constraintKindRadio"
       value="#{pageBean.selectedConstraintKind}"
       layout="pageDirection"
       converter="constraintKindConverter">
       <f:selectItems id="constraintKindItems" value="#{pageBean.constraintKindItems}"/>
       <a4j:support event="onclick" reRender="allPanels"/>
       </h:selectOneRadio>
      
       <!-- ****************************************************** -->
       <!-- radio buttons above show and hide the following panels. -->
       <!-- ****************************************************** -->
       <h:panelGroup id="allPanels">
       <h:panelGroup
       id="ConfigItemAttributePanel"
       rendered="#{pageBean.configItemAttributeKind}">
       <h:inputText id="configItemAttributePath" value="#{pageBean.ciAttributeBean.path}"/>
       <!-- <a4j:support event="onclick" reRender="configItemAttributePath"/> -->
       <rich:suggestionbox
       id="attributePathSuggestBox"
       for="configItemAttributePath"
       var="attributePathSuggestion"
       suggestionAction="#{pageBean.configItemAttributeSuggestions}"
       selfRendered="true">
       <h:column>
       <h:outputText value="#{attributePathSuggestion}"/>
       </h:column>
       </rich:suggestionbox>
       </h:panelGroup>
       <h:panelGroup
       id="FilePropertyPanel"
       rendered="#{pageBean.filePropertyKind}">
       <h:outputText value="file property"/>
       </h:panelGroup>
       <h:panelGroup
       id="ConfigItemCountPanel"
       rendered="#{pageBean.configItemCountKind}">
       <h:outputText value="config item count"/>
       </h:panelGroup>
       </h:panelGroup>
       </h:form>
      </ui:composition>
      </body>
      </html>
      


        • 1. Re: suggestionbox event triggers form submit, second setter

          Myfaces has a specific when the component is processed event the value is not submitted with request. So, it is helpful to use a4j:region if you expect only part of the view should be processed. I.e. around the inputText with suggestion and and around the selectOneRadio

          • 2. Re: suggestionbox event triggers form submit, second setter
            shooali

            I have put <a4j:region> arround the inputText and the suggestionbox (below) but nothing have changed. the inputText property setter is not called when the reRender in the suggesionbox triggers a form submit:

            please help,


            <h:panelGroup
             id="ConfigItemAttributePanel"
             rendered="#{pageBean.configItemAttributeKind}">
             <a4j:region>
             <h:inputText id="configItemAttributePath" value="#{pageBean.ciAttributeBean.path}"/>
             <rich:suggestionbox
             id="attributePathSuggestBox"
             for="configItemAttributePath"
             var="attributePathSuggestion"
             suggestionAction="#{pageBean.ciAttributeBean.configItemAttributeSuggestions}"
             height="200" width="250"
             reRender="ciAttributeOperator">
             <h:column>
             <h:outputText value="#{attributePathSuggestion}"/>
             </h:column>
             </rich:suggestionbox>
             </a4j:region>
             <!-- ********** list box for choosing operator ********* -->
             <h:selectOneMenu id="ciAttributeOperator"
             value="#{pageBean.ciAttributeBean.operator}"
             converter="operatorConverter"
             disabled="#{pageBean.ciAttributeBean.operatorDisabled}">
             <f:selectItems value="#{pageBean.ciAttributeBean.operatorOptions}"/>
             </h:selectOneMenu>
            
            


            • 3. Re: suggestionbox event triggers form submit, second setter

              What is the scope of the pageBean. If it is a request scope and configItemAttributeKind is false bu default, the content inside the h:panelGroup should not processed.

              • 4. Re: suggestionbox event triggers form submit, second setter
                shooali

                The content of the panelGroup is shown. it is the correct constraintkind. the problem is that when I update the path attribute, by using the suggestions returned by the suggestionbox, or even typing 'manually', I want the operatorOptions to get updated as for the new entered path. However, thought the reRender works. the setter of the path property is never called.

                • 5. Re: suggestionbox event triggers form submit, second setter

                  I did not say that content of the panelGroup is not shown. I said that content of the panelGroup is not processed. Those are two different stories.
                  To have the content shown you need to have #{pageBean.configItemAttributeKind} equals true for the sixth phase of JSF lifecycle
                  However, To have the content processed you need to have #{pageBean.configItemAttributeKind} equals true for the second phase of JSF lifecycle

                  • 6. Re: suggestionbox event triggers form submit, second setter
                    shooali

                    excuse me for not understanding.

                    till now, I have used ajax4jsf with many pages and every thing worked fine. I have mainly used a4j:support with reRender and such.
                    Since I have been trying to use richfaces suggestion box, all kind of 'problems' occurs.
                    Why is it, that if I put a4j:support on some inputText on the page with reRender to another selectOneMenu on the page , when the server gets hit, all the properties getters and setters are called. but it if I use rich:suggestionbox on the same inputText with the same reRender to other selectOneMenu, the setter of the inputText property is not called?

                    • 7. Re: suggestionbox event triggers form submit, second setter

                      suggestionbox works in ajaxSingle mode. The parent input field is not submitted in this moment

                      • 8. Re: suggestionbox event triggers form submit, second setter
                        shooali

                        do you have any suggestions please to implement this? I need the selectOneMenu to get updated every time the inputText gets updated (by typing manually or selecting from the suggestion list).

                        BTW, if it works in ajaxSingle mode, why is that if I put it all in the same form, I get the problem I have described at the beginning of this thread, that the selectOneRadio setter is called with null as parameter before the 'isConstraintAttributeKind' mehod?
                        I have solved that by putting the radio buttons in a separate form.

                        Thanks,

                        • 9. Re: suggestionbox event triggers form submit, second setter

                          you can add a4j:support to both h:inputText and rich:suggestionbox . So, it will be two sources for update

                          ajaxSingle just send a special request that include only the field value (and other JSF specific data). However, this does not stop myfaces to process what it should not process

                          • 10. Re: suggestionbox event triggers form submit, second setter
                            shooali

                            thanks,

                            which kind of events can I listen to on the suggestionbox?

                            • 11. Re: suggestionbox event triggers form submit, second setter
                              shooali

                              which event can I listen to on the suggestionbox? I have tried to put a4j:support in the suggestionbox with event="onclick" and event"onchange" and nothing happens....

                              • 12. Re: suggestionbox event triggers form submit, second setter
                                ilya_shaikovsky

                                you may use "onselect" on suggestion box component to update your zone after some value chhosen. And "onkeyup" to update after something typed inside an input.

                                • 13. Re: suggestionbox event triggers form submit, second setter
                                  shooali

                                  thanks,

                                  I want to trigger reRender for the selectOneMenu component, but the onselect attribute of the suggestionbox can call only to a javascript function, not to trigger reRender
                                  ??

                                  • 14. Re: suggestionbox event triggers form submit, second setter
                                    shooali

                                    also, sometimes, on IE, the inputtext bound to the suggestion box seems to get the focus all the time and clicking tab or with the mouse on other component on the screen (like the selectOneMenu component) does not work and the focus stays on the above inputText. In firefox it does not happen.

                                    1 2 Previous Next