edhedges
edhedges

Reputation: 2718

Is it possible to submit a form inside a modal panel and get the results within that same modal panel?

I have this modal panel and I want the user to be able to submit a search from within it and then get the results from that search below in the modal panel. If it is possible could someone point me in the right direction of how to do this? I have searched google but could not find anything.

thanks

Upvotes: 1

Views: 1178

Answers (1)

BalusC
BalusC

Reputation: 1108692

Yes, it's definitely possible. Just submit by ajax and render a part while keeping the dialog open (i.e. do not explicitly close it by synchronous request or by JavaScript).

E.g.

<h:form>
    <h:inputText id="query" value="#{bean.query}" />
    <a4j:commandButton value="Search" action="#{bean.search}" execute="query" render="results" />

    <h:panelGroup id="results">
        <h:dataTable value="#{bean.results}" var="result" rendered="#{not empty bean.results}">
            ...
        </h:dataTable>
    </h:panelGroup>
</h:form>

with

public void search() {
    results = service.search(query);
}

Upvotes: 2

Related Questions