10 Replies Latest reply on May 22, 2006 1:52 PM by Gavin King

    RequestParameter problem

    Mirko Adari Novice

      Okay, it all works fine if I have required get parameter set.
      But what if I don`t? If user enters that page directly without any parameters.
      Then I get error: ould not set field value: cateditor.catid
      And I do not want user to visit page while not in long-running conversation.
      Unfortune @Conversational does not get started, because this error happens.
      Any design patterns to overcome this issue?

      Please help me, it`s needed hurry...

        • 1. Re: RequestParameter problem
          Mirko Adari Novice

          I even can`t use a bean with requestparameter if url does not include requestparmeter. Am I doing smth wrong?

          • 2. Re: RequestParameter problem
            Mirko Adari Novice

            any explanations?

            • 3. Re: RequestParameter problem
              Gavin King Master

              Sorry, no-one can help because it's _your_ explanation which is insufficient.

              • 4. Re: RequestParameter problem
                Mirko Adari Novice

                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"
                 <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 class="tabs_separator"></div>
                 <div class="tab disabled">
                 <div class="tab_l"></div>
                 Grupi muutmine
                 <div class="tab_r"></div>
                 <div class="tabs_separator"></div>
                 <div class="tab choosed">
                 <div class="tab_l"></div>
                 Grupi loomine
                 <div class="tab_r"></div>
                 <div class="tabs_separator"></div>
                 <ui:define name="body">
                 <h1><span class="heading"></span>ANDMED</h1>
                 <div id="andmed">
                 <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"/>
                 <div class="separator"></div>
                 <s:link view="/haldus/mcategory.xhtml" id="submit" value="Loo grupp" action="#{cateditor.create}"
                 buttonClass="button" linkStyle="button"/>
                 <s:link propagation="end" id="submit" value="Loobu"
                 view="/haldus/categorys.xhtml" linkStyle="button" buttonClass="button"/>
                 <div class="separator"></div>

                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;
                public class CategoryEditorBean implements CategoryEditor,Serializable {
                 EntityManager em;
                 private Category category;
                 Logger logger = Logger.getLogger(CategoryEditorBean.class);
                 int catid;
                 Map<String,Category> categoryMap;
                 List<Category> categories;
                 public void loadData() {
                 categories = em.createQuery("from Category c")
                 .setHint("org.hibernate.cacheable", true)
                 Map<String,Category> results = new TreeMap<String,Category>();
                 for (Category category: categories) {
                 categoryMap = results;
                 public void create() {
                 public void save() {
                 public void selectCreate() {
                 category = new Category();
                 public void selectModify() {
                 category = em.find(Category.class,catid);
                 public String delete() {
                 category = em.find(Category.class,catid);
                 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
                  Mirko Adari Novice

                  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 Master

                    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
                      Mirko Adari Novice

                      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 Master

                        It is a String, so the value can be null.

                        • 9. Re: RequestParameter problem
                          Mirko Adari Novice

                          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 Master


                            My logic atleast tells that null = value of 0


                            I have never met any programming language where null==0. Certainly not Java.