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 <[EMAIL PROTECTED]> 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
(ApplicationImpl.java:315)
at
javax.faces.webapp.UIComponentELTag.createComponent
(UIComponentELTag.java:91)
at
javax.faces.webapp.UIComponentClassicTagBase.findComponent
(UIComponentClassicTagBase.java:1101)
at
javax.faces.webapp.UIComponentClassicTagBase.doStartTag
(UIComponentClassicTagBase.java:431)
at
org.
apache.jsp.cmp_005ftargeting_jsp._jspx_meth_h_005fselectOneMenu_005f1
(cmp_005ftargeting_jsp.java:5394)
at
org.apache.jsp.cmp_005ftargeting_jsp._jspx_meth_t_005fcolumn_005f4
(cmp_005ftargeting_jsp.java:5343)
at
org.apache.jsp.cmp_005ftargeting_jsp._jspx_meth_t_005fdataTable_005f3
(cmp_005ftargeting_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:393)
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
(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.ApplicationDispatcher.invoke
(ApplicationDispatcher.java:654)
at
org.apache.catalina.core.ApplicationDispatcher.processRequest
(ApplicationDispatcher.java:445)
at
org.apache.catalina.core.ApplicationDispatcher.doForward
(ApplicationDispatcher.java:379)
at
org.apache.catalina.core.ApplicationDispatcher.forward
(ApplicationDispatcher.java:292)
at
org.
apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch
(ServletExternalContextImpl.java:338)
at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.buildView
(JspViewHandlerImpl.java:481)
at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView
(JspViewHandlerImpl.java:334)
at
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute
(RenderResponseExecutor.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
(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
at
com.todacell.ui.view.filter.OpenSessionInViewFilter.doFilterInternal
(OpenSessionInViewFilter.java:149)
at
com.todacell.ui.view.filter.OncePerRequestFilter.doFilter
(OncePerRequestFilter.java:61)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter
(ExtensionsFilter.java:147)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java: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(Http11Protocol.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;
}