myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guy Bashan <guy.bas...@gmail.com>
Subject RE: Datatable binding problem
Date Sat, 07 Jun 2008 16:14:22 GMT
Hi again,

 

In order to validate set of dropdowns in a datatable, I wrote a method to
extract all components with a specific id (under that datatable), then  scan
the returned values in a loop an and make sure values are properly set.

The method is activated in the save action.

It seems like the drop down component properties: "value" and
"submittedValue" are  null.

(The data is passed to the bean objects properly and saved to database, but
when getting it directly from the component it returns a null value).

 

Am I missing something?

 

Thanks,

Guy.

 

 

From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com] 
Sent: Saturday, June 07, 2008 4:50 PM
To: MyFaces Discussion
Subject: Re: Datatable binding problem

 

You are not understanding how JSF databinding works. I'll give you a brief
overview, but I would strongly recommend that you stop development and read
some articles on control binding before continuing. 

 

The binding happens at component construction time, not render time. If this
does not click, then read my blog at http://andrewfacelets.blogspot.com. 

 

In your case, the binding happens when the component tree is built. Which
means that the data table has no data, no var that is set, etc. A data table
has only one set of components that are re-rendered for each value. There
are not new components for each value. Think of it as a swing tree that has
a node rendered that is called to render every node - there is only one. 


Sent from my iPod


On Jun 7, 2008, at 2:53 AM, Guy Bashan <guy.bashan@gmail.com> wrote:

Hi All,

 

I am having a little problem with datatable and binding.

 

Here is the code:

        <t:dataTable id="dayParts"
value="#{targetingParam.cmpTargetDayParts}"

                     var="dayPart" cellpadding="0" cellspacing="0"
rowIndexVar="rowIndex">

          <t:column style="height:30px" rendered="#{!dayPart.deleted}">

            <h:selectOneMenu value="#{dayPart.startHour}"
onchange="updateTargetingActivity(#{rowIndexParam});"

                             id="hourFrom" styleClass="mform"
style="width:75px;" converter="ByteConverter">

              <f:selectItems value="#{cmp_targeting.dayPartHoursFrom}"/>

            </h:selectOneMenu>

            <div>

              <h:message for="dayParts" errorClass="error_message" />

            </div>

          </t:column>

  </t:dataTable>

 

It works all fine, and I see a table with values on the screen. Now, when I
add binding to the dropdown:

binding="#{dayPart.htmlSelectOneMenuDaypartFrom}"

 

I get the following exception:

org.apache.jasper.el.JspPropertyNotFoundException:
/cmp_targeting.jsp(593,12) '#{dayPart.htmlSelectOneMenuDaypartFrom}' Target
Unreachable, identifier 'dayPart' resolved to null

                at
org.apache.jasper.el.JspValueExpression.setValue(JspValueExpression.java:91)

                at
org.apache.myfaces.application.ApplicationImpl.createComponent(ApplicationIm
pl.java:315)

                at
javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:91
)

                at
javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassi
cTagBase.java:1101)

                at
javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTa
gBase.java:431)

                at
org.apache.jsp.cmp_005ftargeting_jsp._jspx_meth_h_005fselectOneMenu_005f1(cm
p_005ftargeting_jsp.java:5394)

                at
org.apache.jsp.cmp_005ftargeting_jsp._jspx_meth_t_005fcolumn_005f4(cmp_005ft
argeting_jsp.java:5343)

                at
org.apache.jsp.cmp_005ftargeting_jsp._jspx_meth_t_005fdataTable_005f3(cmp_00
5ftargeting_jsp.java:5290)

                at
org.apache.jsp.cmp_005ftargeting_jsp._jspService(cmp_005ftargeting_jsp.java:
1042)

                at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

                at
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

                at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
93)

                at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

                at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

                at
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

                at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)

                at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)

                at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.
java:654)

                at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDis
patcher.java:445)

                at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatch
er.java:379)

                at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher
.java:292)

                at
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(Servl
etExternalContextImpl.java:338)

                at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.buildView(JspViewHandl
erImpl.java:481)

                at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHand
lerImpl.java:334)

                at
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseEx
ecutor.java:41)

                at
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)

                at
org.apache.myfaces.custom.ppr.PPRLifecycleWrapper.render(PPRLifecycleWrapper
.java:84)

                at
javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)

                at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:290)

                at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)

                at
com.todacell.ui.view.filter.OpenSessionInViewFilter.doFilterInternal(OpenSes
sionInViewFilter.java:149)

                at
com.todacell.ui.view.filter.OncePerRequestFilter.doFilter(OncePerRequestFilt
er.java:61)

                at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235)

                at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)

                at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.
java:147)

                at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:235)

                at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:206)

                at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:233)

                at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:175)

                at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
)

                at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)

                at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)

                at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)

                at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

                at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:584)

                at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

                at java.lang.Thread.run(Thread.java:619)

 

In the bean I have the following code:

private transient HtmlSelectOneMenu htmlSelectOneMenuDaypartFrom;

 

  public HtmlSelectOneMenu getHtmlSelectOneMenuDaypartFrom()

  {

    return htmlSelectOneMenuDaypartFrom;

  }

 

  public void setHtmlSelectOneMenuDaypartFrom(HtmlSelectOneMenu
htmlSelectOneMenuDaypartFrom)

  {

    this.htmlSelectOneMenuDaypartFrom = htmlSelectOneMenuDaypartFrom;

  }

 

i:embed'>  {

    this.htmlSelectOneMenuDaypartFrom = htmlSelectOneMenuDaypartFrom;

  }

 


Mime
View raw message