please help me, component binding not work

Hi

I have a HtmlSelectManyPicklist in backend and I want to bind it in my xhtml.

when I set value from server at first time, it works fine but when I click on button to submit the form an exception is thrown with following message:

exception when I press submit button:

ERROR Servlet.service()for servlet Faces Servlet threw exception

javax.faces.el.PropertyNotFoundException: /pages/main/selectColumn.xhtml @26,18 binding="#{userSetting.picklist}": Target Unreachable, identifier'userSetting' resolved tonull

at com.sun.facelets.el.LegacyValueBinding.isReadOnly(LegacyValueBinding.java:84)

at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:68)

at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:41)

at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:78)

at org.apache.myfaces.shared_impl.util.RestoreStateUtils.recursivelyHandleComponentReferencesAndSetValid(RestoreStateUtils.java:41)

at org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:179)

at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)

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

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

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

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

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

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:29)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.jboss.seam.servlet.SeamCharacterEncodingFilter.doFilter(SeamCharacterEncodingFilter.java:41)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

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

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

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

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

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

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

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

the code in server side to create a new instance of component is:

Application app = FacesContext.getCurrentInstance().getApplication();

picklist = (HtmlSelectManyPicklist) app.createComponent(HtmlSelectManyPicklist.COMPONENT_TYPE);

picklist.setValueBinding("picklist", app.createValueBinding("#{userSetting}"));

the code in my xhtml file :

<s:selectManyPicklist size="5" binding="#{userSetting.picklist}"

>

<s:selectItems value="#{userSetting.columnHeaders}" var="column"

itemValue="#{column.name}" itemLabel="#{column.label}" />

</s:selectManyPicklist>

<h:commandButton value="Submit" class="button" action="#{userSetting.display}"/>

lots of thanks

[5058 byte] By [java1357a] at [2007-11-26 19:07:26]
# 1
By the way, I am using Myfaces 1.5 and facelets and I put setter and getter for the "picklist" component.thank again
java1357a at 2007-7-9 20:59:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
The error message is clear.app.createValueBinding("#{userSetting}"));This property cannot be resolved.
BalusCa at 2007-7-9 20:59:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

but If I remove that line the exception will remain.

anothr thing is that, I am using JBoss Seam Freamework and it is Seam that manage the backing beans and create them. and I know in that time the userSetting bean exists.

I dont know whether I have to put that line (app.createValueBinding("#{userSetting}")); or not.

if yes, what shall I put instead of "#{userSetting}"?

java1357a at 2007-7-9 20:59:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

the code in server side to create a new instance of

component is:

Application app =

=

FacesContext.getCurrentInstance().getApplication();

picklist = (HtmlSelectManyPicklist)

t)

app.createComponent(HtmlSelectManyPicklist.COMPONENT_

YPE);

picklist.setValueBinding("picklist",

", app.createValueBinding("#{userSetting}"));

the code in my xhtml file :

<s:selectManyPicklist size="5"

binding="#{userSetting.picklist}"

:selectItems value="#{userSetting.columnHeaders}"

var="column"

itemValue="#{column.name}"

lumn.name}" itemLabel="#{column.label}" />

</s:selectManyPicklist>

<h:commandButton value="Submit"

class="button" action="#{userSetting.display}"/>

I haven't used selectManyPicklist . But , are you sure you want to bind it to the Component ? Can't you just bind the value attribute to some Backing Bean data type something like a String array?

1)

You can try the server side code that you have put in the BackingBean's constructor. or

2) Have a instance variable of type HtmlSelectManyPicklist with getter and setter in your Backing Bean and bind it as follows.

HtmlSelectManyPicklist picklist;

public getPicklist (){

return picklist;

}

<s:selectManyPicklist size="5"

binding="#{BackingBean.picklist}"

Hope this solves your problem.

Karthik>

Akash_Gangaa at 2007-7-9 20:59:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Akash_Ganga,

I put both setter and getter in server-side.

the picklist is the same as HtmlSelectManyListBox and I took a look at the source I saw it is just extends from that.

about removing binding, yes you right, I test it without binding and it worked fine.

but I am curious about this issue because whenever I try this binding I failed and ended up with leaving it. I want to know what is the problem and how it works

thanks

java1357a at 2007-7-9 20:59:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

you dont need that java code that you have put in the server side. You just need the getter and setter method and bind it to the tag.

You will need the code only when you want to read the some value

ValueBinding vb =

FacesContext.getCurrentInstance().getApplication().createValueBinding("#{sessionScope.something}");

Object someValue = vb.getValue(FacesContext.getCurrentInstance());

You generally bind it to a component when you want to do some dynamic changes to the component, say some thing like changing the style attribute, size of the select many box etc. If you do not have any such requirement, you can just bind the value attribute to some backing bean data type and access the values in the BackingBean.

If you definitely want to bind it to a component,

1) HtmlSelectManyListBox pickList= new HtmlSelectManyListBox ();

2) Add getter and Setter methods,

3) and add the binding attribute as follows to the tag.

binding="#{ManagedBeanName.pickList}"

You dont need anything else.

Akash_Gangaa at 2007-7-9 20:59:50 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...