Pregunta

I have two forms (one for some filter-settings, and the other for the content)

If I set some filter settings in the first form (e.g. "show only not empty chapters") with

<h:form>
    <!-- some checkboxes -->
    <h:commandButton value="Save filter settings" id="filterBUtton">
        <f:ajax event="click" execute="@form" render="@all" listener="#{bean.saveFilter}"/>
    </h:commandButton>
</h:form>

and try to execute a actionlistener from the second form (e.g. to display all found chapters), it doen't execute the command as ajax request (the view is lost somehow?) - and then my Filters say "stop! you are not an ajax request, so you can't pass here"

here is my second form (which is, like the first one, received from template):

<h:form>
    #{bean.foundChapters} have been found. Show them now?
    <h:commandButton value="Show them!" id="showThem">
        <f:ajax event="click" render=":result" listener="#{bean.loadAndShowChapters}"/>
    </h:commandButton>
</h:form>
<h:panelGrid id="result">
    <!-- List of results... -->
</panelGrid>

here is my second method which makes the view crash (and is not submitted by ajax) (the first has a similar interface):

public void loadAndShowChapters(AjaxBehaviorEvent event){
    System.out.println("force:true");
    forceLoad = true;
    doQuery(); //does the loading (so the results can be displayed in 
}

The funny thing is that if I move the 'showThem' Button from form 2 to form 1, it works fine. Seems it has problems handling two forms? Two forms can't be a problem, am I right?

Can anyone help here pls?

¿Fue útil?

Solución

thanks for your anwser,

I have solved it by

  1. adding a ID to the form and
  2. solve a Javascript-problem (it tried to find a element by document.getElementById('notExistantForm:element') onclick. After correctly defining the id, it worked again!
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top