Newbie to struts here.
I'm trying to create a search form that, when submitted, displays the search results on the same page. Right now I am encountering an infinite loop due to my action mapping (included below). What's happening (I stepped through using remote debugging) is that my actionform validate AND my actual action which does the search is being executed even before the page is rendered. I can understand the actionform but why is the action being executed? The action returns to the success mapping which is the same page.. resulting in the infinite loop. Incase it gets asked.. I do have to have them both on the same page.
What is the "best practices" way to tell an action not to execute unless submit is clicked.. query string parameters for example?
-- exceprt from struts-config.xml
<form-bean name="search"
type="forms.searchFormBean"/>
...
<action path="/Search"
type="actions.MySearchAction"
input="/Search.do"
name="search"
scope="request">
<forward name="success" path="/Search.do"/>
</action>
--- search.jsp
<html:form action="Search.do" >
<html:text property="keywords"/><br/>
<html:submit>Search</html:submit><br/>
</html:form>
I'm trying to create a search form that, when submitted, displays the search results on the same page. Right now I am encountering an infinite loop due to my action mapping (included below). What's happening (I stepped through using remote debugging) is that my actionform validate AND my actual action which does the search is being executed even before the page is rendered. I can understand the actionform but why is the action being executed? The action returns to the success mapping which is the same page.. resulting in the infinite loop. Incase it gets asked.. I do have to have them both on the same page.
What is the "best practices" way to tell an action not to execute unless submit is clicked.. query string parameters for example?
-- exceprt from struts-config.xml
<form-bean name="search"
type="forms.searchFormBean"/>
...
<action path="/Search"
type="actions.MySearchAction"
input="/Search.do"
name="search"
scope="request">
<forward name="success" path="/Search.do"/>
</action>
--- search.jsp
<html:form action="Search.do" >
<html:text property="keywords"/><br/>
<html:submit>Search</html:submit><br/>
</html:form>