Adding that line really doesn't go along with the spirit of
valueBindings, though.  Ideally, you want the ValueBinding to be
evaluated as late as necessary, preferably just before the UIComponent
is rendered (which is when most ValueBindings are referenced, in the
renderer).


On Sun, 2 Jan 2005 16:41:55 -0800 (PST), Ray Clark <[EMAIL PROTECTED]> wrote:
>  
> Well, I played around and I found a solution to my value binding problem. 
>   
> In the tag I have a setValueBinding method that I copied from the Core
> JavaServerFaces book.  It looks like this now: 
>   
> public void setValueBinding(UIComponent component, String attributeName, 
>           String attributeValue) { 
>   
>      FacesContext context = FacesContext.getCurrentInstance(); 
>      Application app = context.getApplication(); 
>      ValueBinding.vb = app.createValueBinding(attributeValue); 
>      component.setValueBinding(attributeName, vb); 
>      // Adding this line of code makes it work 
>      component.getAttributes().put(attributeName, vb.getValue(context)); 
> } 
>   
> I noticed that the Renderer was getting the value from the
> component.getAttributes.  So I added the put and it started working.  I'm
> not sure if this is what should have been done, but it certainly does the
> job.  The tag extends the UIComponentTag.  Since this 1 line fixed the
> problem I didn't think anyone would need any other code.  Let me know if you
> do though. 
>   
> As I said, this worked fine with JSF 1.1.01 without the 1 line that I had to
> add. 
>   
> Hope this helps someone to figure out what the problem was. 
>   
> Thanks, 
> Ray
> 
> 
> Heath Borders <[EMAIL PROTECTED]> wrote: 
> Date: Sun, 2 Jan 2005 11:22:46 -0600
> From: Heath Borders 
> To: Ray Clark 
> Subject: Re: ValueBinding
> 
> 
> Make sure to let us know the answer if you find it. :)
> 
> 
> On Sun, 2 Jan 2005 08:41:03 -0800 (PST), Ray Clark wrote:
> > Thank you for your response. I need to trim down my
> > code so that it centers on the problem before I post
> > it. When I get that done I'll post. It may be a
> > couple of days. Who knows, I may stumble across the
> > answer in the meantime.
> > 
> > Thanks,
> > Ray
> > 
> > --- Heath Borders wrote:
> > 
> > > Send your code for the getter/setter in your
> > > component, and the jsp
> > > code that you're drives the whole thing. The
> > > problem must be there
> > > then.
> > >
> > >
> > > On Sat, 1 Jan 2005 12:13:32 -0800 (PST), Ray Clark
> > > wrote:
> > > > I just noticed a problem with my value binding
> > > under myface. My value
> > > > binding works the way that it is coded with JSF
> > > 1.1.01, but doesn't work
> > > > with myfaces 1.0.7. I was wondering if anyone
> > > could tell me the right way
> > > > to code this for myfaces?
> > > >
> > > > Here is my code that works for JSF 1.1.01. I got
> > > it right out of the Core
> > > > JavaServerFaces book:
> > > >
> > > > public void setProperties(UIComponent component) {
> > >
> > > > super.setProperties(component);
> > > >
> > > > setString(component, "rowSpan", rowSpan);
> > > > }
> > > > public void setString(UIComponent component,
> > > String attributeName, String
> > > > attributeValue) {
> > > > if (attributeValue == null) {
> > > > return;
> > > > } else {
> > > > if (isValueReference(attributeValue)) {
> > > > setValueBinding(component,
> > > attributeName, attributeValue);
> > > > } else {
> > > >
> > > component.getAttributes().put(attributeName,
> > > attributeValue);
> > > > }
> > > > }
> > > > }
> > > > public void setValueBinding(UIComponent component,
> > > String attributeName,
> > > > String attributeValue) {
> > > > FacesContext context =
> > > FacesContext.getCurrentInstance();
> > > > Application app = context.getApplication();
> > > > ValueBinding vb =
> > > app.createValueBinding(attributeValue);
> > > > component.setValueBinding(attributeName, vb);
> > >
> > > > }
> > > >
> > > > Then in the renderer for this tag I have:
> > > >
> > > > String rowSpan = (String)
> > > rptTableCol.getAttributes().get("rowSpan");
> > > >
> > > > this always returns null. But the attributeValue
> > > in the tag has the right
> > > > code in it. So I don't understand why this works
> > > with JSF 1.1.01 and not
> > > > myfaces 1.0.7. Was this a bug in the version of
> > > the RI that myfaces 1.0.7
> > > > is using?
> > > >
> > > > Any typos are because I typed it in. I can't cut
> > > and paste my code into
> > > > this pc (long story lol). The value
> > > >
> > > > Thanks,
> > > > Ray
> > > >
> > > >
> > > >
> > > > ________________________________
> > > > Do you Yahoo!?
> > > > Yahoo! Mail - Helps protect you from nasty
> > > viruses.
> > > >
> > > >
> > >
> > >
> > > --
> > > -Heath Borders-Wing
> > > [EMAIL PROTECTED]
> > >
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > Meet the all-new My Yahoo! - Try it today!
> > http://my.yahoo.com
> > 
> > 
> 
> 
> -- 
> -Heath Borders-Wing
> [EMAIL PROTECTED]
> 
> 
>  ________________________________
> Do you Yahoo!?
>  Jazz up your holiday email with celebrity designs. Learn more. 
> 
> 


-- 
-Heath Borders-Wing
[EMAIL PROTECTED]

Reply via email to