-
1. Re: RequestParameter problem
mirko27 May 21, 2006 10:30 AM (in response to mirko27)I even can`t use a bean with requestparameter if url does not include requestparmeter. Am I doing smth wrong?
-
2. Re: RequestParameter problem
mirko27 May 22, 2006 5:42 AM (in response to mirko27)any explanations?
-
3. Re: RequestParameter problem
gavin.king May 22, 2006 5:44 AM (in response to mirko27)Sorry, no-one can help because it's _your_ explanation which is insufficient.
-
4. Re: RequestParameter problem
mirko27 May 22, 2006 7:39 AM (in response to mirko27)Sorry. I`ll try better.
I have this page:<?xml version="1.0" encoding="iso-8859-15"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:s="http://jboss.com/products/seam/taglib"> <body> <ui:composition template="templates/layout.xhtml"> <ui:define name="tabs"> <div class="tab enabled"> <div class="tab_l"></div> <a href="categorys.jsf">#{msgs.allCategories}</a> <div class="tab_r"></div> </div> <div class="tabs_separator"></div> <div class="tab disabled"> <div class="tab_l"></div> Grupi muutmine <div class="tab_r"></div> </div> <div class="tabs_separator"></div> <div class="tab choosed"> <div class="tab_l"></div> Grupi loomine <div class="tab_r"></div> </div> <div class="tabs_separator"></div> </ui:define> <ui:define name="body"> <h1><span class="heading"></span>ANDMED</h1> <div id="andmed"> <h:form> <s:validateAll> <span class="errors"><h:message for="name"/></span> <h:outputLabel for="name" value="Grupi nimi"/> <h:inputText id="name" value="#{category.name}" styleClass="field"/> <div class="separator"></div> <span class="errors"><h:message for="head"/></span> <h:outputLabel for="head" value="Tüvikategooria"/> <h:outputText id="head" value="#{category.head.name}" styleClass="field"/> <div class="separator"></div> <span class="errors"><h:message for="showed"/></span> <h:outputLabel for="showed" value="Avalik"/> <h:selectOneRadio id="showed" value="#{category.showed}" styleClass="field"> <f:selectItem itemValue="true" itemLabel="Jah"/> <f:selectItem itemValue="false" itemLabel="Ei"/> </h:selectOneRadio> <div class="separator"></div> <s:link view="/haldus/mcategory.xhtml" id="submit" value="Loo grupp" action="#{cateditor.create}" buttonClass="button" linkStyle="button"/> </s:validateAll> <s:link propagation="end" id="submit" value="Loobu" view="/haldus/categorys.xhtml" linkStyle="button" buttonClass="button"/> <div class="separator"></div> </h:form> </div> </ui:define> </ui:composition> </body> </html>
and this bean:package ee.digizone.ejb; import java.io.Serializable; import java.util.List; import java.util.Map; import java.util.TreeMap; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.persistence.EntityManager; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Begin; import org.jboss.seam.annotations.Conversational; import org.jboss.seam.annotations.Create; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.End; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.annotations.RequestParameter; import org.jboss.seam.annotations.Scope; import ee.digizone.entity.Category; import org.jboss.logging.Logger; @Stateful @Name("cateditor") @Conversational(ifNotBegunOutcome="categorys") public class CategoryEditorBean implements CategoryEditor,Serializable { @In(create=true,value="digizoneDatabase") EntityManager em; @Out(required=false) @In(required=false) private Category category; Logger logger = Logger.getLogger(CategoryEditorBean.class); @RequestParameter int catid; Map<String,Category> categoryMap; List<Category> categories; @Create public void loadData() { categories = em.createQuery("from Category c") .setHint("org.hibernate.cacheable", true) .getResultList(); Map<String,Category> results = new TreeMap<String,Category>(); for (Category category: categories) { results.put(category.getName(),category); } categoryMap = results; } public void create() { em.persist(category); } public void save() { em.refresh(category); } @Begin(join=true) public void selectCreate() { category = new Category(); category.setHead(em.find(Category.class,catid)); } @Begin(join=true) public void selectModify() { category = em.find(Category.class,catid); } @End public String delete() { category = em.find(Category.class,catid); em.remove(category); return null; } public Map<String,Category> getCategories() { return categoryMap; } public Category getCategory() { return this.category; } @Destroy @Remove public void destroy() {} }
What I wan`t is that when user hits page ccategory.jsf when no conversation is active ,he would be directed to categorys page. Currently it just gaves me error: could not set cateditor.catid.
Hope this one is better, I know five languages, but english is not in them... so be merciful to me. -
5. Re: RequestParameter problem
mirko27 May 22, 2006 8:55 AM (in response to mirko27)It gives me trouble every time when i call bean which has requestparameter, but request does not have that parameter.
Giving errors and not letting me work normally. There most definitely is something that im designing wrong... -
6. Re: RequestParameter problem
norman.richards May 22, 2006 11:32 AM (in response to mirko27)A missing request parameter is a null value. If you want to allow null values, you need to use a non-primitive type like Integer instead of int.
-
7. Re: RequestParameter problem
mirko27 May 22, 2006 11:39 AM (in response to mirko27)Oh my god, thank you. But how come does not entry.jsf on blog example does not break application if I make a request with not specifying blogEntryID parameter?
-
8. Re: RequestParameter problem
norman.richards May 22, 2006 1:00 PM (in response to mirko27)It is a String, so the value can be null.
-
9. Re: RequestParameter problem
mirko27 May 22, 2006 1:06 PM (in response to mirko27)yeah, noticed it. Anyway thank you much. You should note it in manual I think... My logic atleast tells that null = value of 0 or smth.
-
10. Re: RequestParameter problem
gavin.king May 22, 2006 1:52 PM (in response to mirko27)My logic atleast tells that null = value of 0
Um.
I have never met any programming language where null==0. Certainly not Java.