6 Replies Latest reply on Aug 20, 2009 4:51 AM by nmaric

    h:inputText inside rich:datatable

    nmaric

      Hi,

      can someone tell me what i am doing wrong with this.

      i have list (List) in MyBean. also, declared HtmlDataTable object for binding rich:datatable to bean.

      in table, in jsp part, i have inputs that could be changed. there are inputtext and selectOneMenu.
      the problem is when i submit changes from form they are not visible on BackingBean. here is a code, so maybe you will see mistakes.

      thanks in advance!!!

      class SomeObject {
      private String type;
      private String value;
      public void setType(String type) {
      this.type = type;
      }
      public String getType() {
      return type;
      }
      public void setValue(String value) {
      this.value = value;
      }
      public String getValue() {
      return value;
      }
      }


      class MyBean {
      List list = new ArrayList();
      HtmlDataTable table;

      ....
      getters/setters
      ....

      public String onContinue() {
      .....
      //here i don't see changes that i made on form
      }
      }

      View.jsp

      ....
      <rich:dataTable id="objects" binding="#myBean.table}"
      value="#{myBean.list}" var="obj">

      ...
      <rich:column>
      <h:inputText id="input_value" value="#{obj.value}" />
      </rich:column>
      <rich:column>
      <h:selectOneMenu id="select_type" value="#{obj.type}">
      <f:selectItem itemLabel="type1" itemValue="type1" />
      <f:selectItem itemLabel="type2" itemValue="type2" />
      <f:selectItem itemLabel="type3" itemValue="type3" />
      </h:selectOneMenu>
      </rich:column>
      .....
      </rich:dataTable>
      <a4j:commandLink id="continueLink" immediate="true" action="#{myBean.onContinue}">
      <h:graphicImage value="/images/butt-continue.gif" />
      </a4j:commandLink>
      ....


        • 1. Re: h:inputText inside rich:datatable
          ilya_shaikovsky

          why do you need the binding in general?

          binding to component should be request scoped.

          • 2. Re: h:inputText inside rich:datatable
            nmaric

            i use it for rowIndex 'cause i have to have button to reset particular row to default values, before changing. also, have to add new rows and some other things that is already implemented into HtmlDataTable

            i changed scope to request, but still the same

            • 3. Re: h:inputText inside rich:datatable
              ilya_shaikovsky

              also remove immediate from command link.

              • 4. Re: h:inputText inside rich:datatable
                nmaric

                good morning.

                i removed binding from table but still there is no changes.
                i am stuckand can't see what i am doing wrong. please help.


                here is all code:

                datatable.jsp:
                <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
                <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
                <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
                <%@ taglib uri="/WEB-INF/my_custom_tags.tld" prefix="custom"%>


                <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
                Inputtext inside datatable


                <f:view>
                <h:form id="mainForm">
                <a4j:region>
                <rich:dataTable id="objects" value="#{myBean.list}" var="obj">
                <rich:column>
                <h:inputText id="input_value" value="#{obj.value}" />
                </rich:column>
                </rich:dataTable>
                <a4j:commandLink id="continueLink" immediate="true" action="#{myBean.onContinue}">
                <h:graphicImage value="/images/butt-continue.gif" />
                </a4j:commandLink>
                </a4j:region>
                </h:form>
                </f:view>



                MyBean.java
                class MyBean{
                private List list = null;
                public List getList() {
                if (list == null) {
                list = new ArrayList();
                SomeObject obj = new SomeObject();
                obj.setValue("1");
                list.add(obj);
                obj = new SomeObject();
                obj.setValue("2");
                list.add(obj);
                obj = new SomeObject();
                obj.setValue("3");
                list.add(obj);
                }
                return list;
                }
                public String onContinue () {
                for (SomeObject obj : list) {
                System.out.println("obj.getValue()...." + obj.getValue());
                }
                return null;
                }
                }
                SomeObject.java

                class SomeObject {
                private String type;
                private String value;
                public void setType(String type) {
                this.type = type;
                }
                public String getType() {
                return type;
                }
                public void setValue(String value) {
                this.value = value;
                }
                public String getValue() {
                return value;
                }
                }




                • 5. Re: h:inputText inside rich:datatable
                  ilya_shaikovsky

                  see my previous comment.

                  • 6. Re: h:inputText inside rich:datatable
                    nmaric

                    that's it!!!
                    it works!!

                    now i noticed some other bugs :) but at least i can go forward.
                    i used immediate 'cause link didn't work at all without it. but now i see that problem isn't in link, the problem is somewhere inside datatable.

                    thanks, again :)