Hi everybody,
First, sorry for my English.
I am newbie with Struts (only 1 week), so I don't understand it very well.
I am trying to develop an application which has a page with a form
search in which I want to show the results of the same one.
I did an ActionForm (with all the parameters of the form and two
collections; one for the results of the search and other to fill up a
html:select), and an Action class:
<code>
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
SearchForm formSearch = (SearchForm) form;
String a = ((SearchForm) form).getA();
String b= ((SearchForm) form).getB();
int c = (( SearchForm) form).getC();
int d = ((SearchForm) form).getD();
String e = ((SearchForm) form).getE();
int f = ((SearchForm) form).getF();
String g = ((SearchForm) form).getG();
int h = ((SearchForm) form).getH();
SearchBean bean = new SearchBean(a,b, c, d,e, f, g, h);
String page= request.getParameter("page");
if (page== null) page= "1";
String user = (String) request.getSession().getAttribute("USERNAME");
MyFacade facade = new MyFacade(user);
Collection types= new Vector();
types.add(new LabelValueBean("AS","AS"));
types.add(new LabelValueBean("WF","WF"));
types.add(new LabelValueBean("HJ", "HJ"));
Collection results = facade.findResults(bean, Integer.parseInt(page));
formSearch.setResultList(results);
request.setAttribute("types", types);
return mapping.findForward("success");
}
</code>
My struts-config.xml
<code>
<form-beans>
<form-bean name="searchForm" type="my.controller.forms.SearchForm"/>
</form-beans>
<global-exceptions/>
<global-forwards>
<forward name="search" path="/pages/search.jsp" redirect="true"/>
</global-forwards>
<action-mappings>
<action path="/search" type="my.controller,action.MyAction"
name="searchForm" input="/pages/search.jsp" scope="session">
<forward name="sucess" path="/busqueda.do" redirect="false"/>
</action>
</action-mappings>
</code>
And the jsp:
<code>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<html>
<head>
<title>Search</title>
</head>
<body>
<h1>Search</h1>
<html:errors />
<table>
<html:form action="/search">
<tr>
<td><bean:message key="search.a" /></td>
<td><html:text property="a" /></td>
</tr>
...........
...........
<tr>
<td><bean:message key="search.type" /></td>
<td>
<html:select property="c" >
<html:options collection="types"
property="label" labelProperty="value" />
</html:select> </td>
</tr>
<tr>
<td><html:submit /></td>
<td><html:cancel /></td>
</tr>
</html:form>
</table>
<br />
<table>
</table>
</body>
</html>
</code>
First, when I click on submit button, struts doesn't find any forward
page, action.
I know it may be very simple thing but I would like that you could help me .
Thanks all
|