Navigation problems
thelonius Dec 1, 2009 5:20 PMHello everybody!
I recently started working with JBoss Seam and am amazed by the potential of this framework. However there is one issue I could not tackle so far. It is page navigation. I already read through quite some tutorials and examples and am convinced that my settings are correct, however when I run my website i do not get redirected.
(Code follows)
If I enter a search term on my home.xhtml and click the search button Seam does call the search function, however after it successfully finished (and found the correct amount of list items) I end up on the home.xhtml again, as if nothing happened, instead of being redirected to search_result.xhtml. This is only one example, redirects on other pages, like registration, do not work either.
Can anyone see what I am doing wrong?
Any help is greatly appreciated.
Cheers,
Ole
home.page.xml
<?xml version="1.0" encoding="UTF-8"?> <page xmlns="http://jboss.com/products/seam/pages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd"> <navigation from-action="#{itemFinder.search}"> <rule> <redirect view-id="/search_result.xhtml"/> </rule> </navigation> </page>
ItemFinderBean.java
@Stateful @Name("itemFinder") public class ItemFinderBean implements ItemFinder { static final String EJBQL = "select item from Item item "; @PersistenceContext EntityManager em; @In @Out(required = false) String criteria; @DataModelSelection @Out(required=false) Item item; @DataModel private List<Item> results; public void search() { StringBuilder searchPattern = new StringBuilder(); searchPattern.append("%"); if (criteria != null && criteria.trim().length() != 0) { searchPattern.append(criteria.toLowerCase().replace('*', '%')).append('%'); } results = em.createQuery(EJBQL + "WHERE lower(item.title) LIKE :search " + "OR lower(item.description) LIKE :search") .setParameter("search", searchPattern.toString()).getResultList(); } public void showItem() { if (item == null) throw new ItemNotFoundException(); } @Remove @Destroy public void destroy(){} }
Snippet from home.xhtml
<h:form> <table> <tr> <td><h1>Suche</h1></td><td><h:inputText value="#{criteria}" /></td> <td><h:commandButton type="submit" value="Finden!" action="#{itemFinder.search}" /></td> </tr> <tr><td></td><td><a >Erweiterte Suche</a></td></tr> </table> </h:form>