I have this search page. On it is an input field and a submit button.
The search page is bound to the URL /search . When I submit a search,
I want that query embedded in the URL like this: /search/query For
example, if you search for "alpha", the url should look like
/search/alpha
I tried to do this, I made annotation look like this:
@UrlBinding("/search/{query}") But the url stays at /search when I
submit the search form. As a result, when I hit the refresh button, it
gives me a popup saying "This is post data and refreshing may not work"
or something like that.
The only solution I've found to this is to change the form's
method="GET". But when I do that, the url doesn't look like
/search/alpha, it looks like this:
/search?query=alpha&search=Search&_sourcePage=%2FWEB-INF%2Fjsp%2Fsearch.
jsp&__fp=
Here's the code in my action bean:
@UrlBinding("/search/{query}")
public class SearchActionBean extends MyActionBean {
@SpringBean
private SearchDao searchDao;
private String query;
private List<SearchResultDto> results = new
ArrayList<SearchResultDto>();
@DefaultHandler
@DontBind
@DontValidate
public Resolution goToSearch() {
return new ForwardResolution("/WEB-INF/jsp/search.jsp");
}
public Resolution search() {
if (query != null) {
results = searchDao.search(query);
}
return new ForwardResolution("/WEB-INF/jsp/search.jsp");
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public List<SearchResultDto> getResults() {
return results;
}
public void setResults(List<SearchResultDto> results) {
this.results = results;
}
}
And here's my JSP:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="stripes"
uri="http://stripes.sourceforge.net/stripes.tld" %>
<[EMAIL PROTECTED] prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<[EMAIL PROTECTED] prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<[EMAIL PROTECTED] prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<[EMAIL PROTECTED] prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<stripes:layout-render name="/WEB-INF/jsp/layout/template.jsp">
<stripes:layout-component name="pageTitle">Search |
StartFound</stripes:layout-component>
<stripes:layout-component
name="menuSelect">search</stripes:layout-component>
<stripes:layout-component name="centerContent">
<my:messages messages="${messages}"/>
<h1>Search</h1>
<p>
<stripes:form
beanclass="com.haverlocke.tellah.web.actionbean.SearchActionBean"
method="GET">
<center id="search">
<stripes:text name="query" size="60"></stripes:text>
<stripes:submit name="search" value="Search"/>
</center>
</stripes:form>
</p>
<c:if test="${! empty actionBean.results}">
<h1>Results</h1>
<c:forEach var="result" items="${actionBean.results}">
<p><stripes:link
beanclass="com.haverlocke.tellah.web.actionbean.CompanyActionBean">
<stripes:param name="name" value="${result.name}"/>
${result.name} -
${result.whatItDoes}</stripes:link></p>
</c:forEach>
</c:if>
</stripes:layout-component>
</stripes:layout-render>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users