1

I have two forms: one to define some filter settings (ajax) and with sumbit buttons which reloads the page by action="null" and one form with a single command button which executes the ajax listener "#{bean.activate}":

<h:form id="settingsForm">
  <h:selectBooleanCheckbox value="#{bean.boolean1}" id="bool1">
      <f:ajax event="click" render="@all" execute="bool1"/>
  </h:selectBooleanCheckbox> 

  <ui:repeat var="step" value="#{bean.availableSteps}">
    <h:commandLink action="#{bean.navigate(step)}"> 
      <h:outputText value="#{step.name}" />
    </h:commandLink>
  </ui:repeat>
</h:form>

<h:form id="activateForm">
  <h:commandButton value="set activate bool and rerender" >
    <f:ajax event="click" execute="@form" render="@all" listener="#{bean.activate}"/>    
  </h:commandButton>
</h:form>

The problem is following:

when I change the checkbox (boolean in backing bean) and click the submit button in the same form, only the changes (in the backing bean) are persisted which were set in the same form.

When I execute the second form (bean.activate), it rerenders fine (shows some more information), but when I THEN submit the first form, the changes of the second form are lost (but they are working on the same bean). I want that it remembers also the variables set in the second form...

It seems that the values set by the other form are not persisted, because when i perform a form submit, all the "information" stored by ajax of the second form is lost.

e.g.

boolean boolean1 = false; //set by form 1

boolean show = false;  //set by form 2 (ajax)  

public void activate(Ajaxbehaviour...){ show = true; }

Should there be by default only ONE form at all? it seems that two forms (one big and one just so set a variable by ajax) are too much...

Niko
  • 1,024
  • 4
  • 24
  • 50
  • Where's the code? You've neglected to show actual relevant code which you yourself have stated may be the source of the problem – kolossus Aug 08 '13 at 20:14
  • Your question is a bit too long winded. Just state the requirement, the code and the problem with it. That should be it. As to your concrete problem, is your bean request scoped instead of view scoped or so? – BalusC Aug 09 '13 at 00:48
  • @BalusC he has two forms. – kinkajou Aug 09 '13 at 00:50
  • @Kitex: That's correct. Your point being? – BalusC Aug 09 '13 at 00:50
  • @BalusC will that alter data he is submitting? – kinkajou Aug 09 '13 at 00:52
  • hi, the bean is view scoped. as Kitex said, the question is if the data of form 1 is altered when I sumbit form 2? just in general. If you need further code, tell me pls – Niko Aug 09 '13 at 07:03
  • Lets say: – Niko Aug 09 '13 at 07:05
  • @Niko, rephrase your question by adding the information you have provided in the comments. Keep the question shorter, by explaining the concrete problem and providing the relevant code, thanks – perissf Aug 09 '13 at 07:34
  • Please check if this can help you: http://stackoverflow.com/questions/7807334/rendering-other-form-by-ajax-causes-its-view-state-to-be-lost-how-do-i-add-this or http://stackoverflow.com/questions/11408130/jsf-commandbutton-works-on-second-click – perissf Aug 09 '13 at 08:36

0 Answers0