MyFaces spec:
http://java.sun.com/j2ee/javaserverfaces/download.html
On Thu, 6 Jan 2005 19:54:08 -0800 (PST), Ray Clark <[EMAIL PROTECTED]> wrote:
> Does anyone know why in my renderer this line of code
> returns null? (The attribute colClass uses
> valueBinding. And by the way, it worked fine in JSF
> 1.1.01 but like I said returns null in myFaces 1.0.7.)
>
> String colClass = (String)
> rptTableCol.getAttributes().get("colClass");
>
> But this set of code works.
>
> vb = rptTableCol.getValueBinding("colClass");
> String colClass = null;
> if (vb == null) {
> colClass = (String)
> rptTableCol.getAttributes().get("colClass");
> } else {
> colClass = (String) vb.getValue(context);
> }
>
> It seems that the JSF 1.1.01 get method checks to see
> if valueBinding exists for this attribute and returns
> the value from it if it does. But in myFaces it
> doesn't work that way.
>
> Anyone know why?
>
> If not, can someone give me a link to the MyFaces spec
> so that maybe I can try and figure it out? :)
>
> Thanks,
> Ray
>
> --- Heath Borders <[EMAIL PROTECTED]> wrote:
>
> > I'm not sure, you might have to check the MyFaces
> > spec and see.
> >
> >
> > On Thu, 6 Jan 2005 18:15:58 -0800 (PST), Ray Clark
> > <[EMAIL PROTECTED]> wrote:
> > > I don't understand what you mean. You said "the
> > > attributes map in the RI might do the ValueBinding
> > > checking for you". But when I had
> > > "rptTableCol.getAttributes().get("colSpan")" it
> > was
> > > returning null when colSpan used value binding.
> > That
> > > was my problem, to get around that I had to do the
> > > check that I mentioned. I agree with you that the
> > > attributes map might do the check for me, and it
> > seems
> > > to in JSF 1.1.01, but it doesn't in myFaces 1.0.7.
> > So
> > > if what you are saying is true, then is there a
> > bug in
> > > the RI in myFaces 1.0.7?
> > >
> > > Thanks,
> > > Ray
> > >
> > > --- Heath Borders <[EMAIL PROTECTED]> wrote:
> > >
> > > > Well, the attributes map in the RI might do the
> > > > ValueBinding checking for you.
> > > >
> > > >
> > > > On Wed, 5 Jan 2005 18:42:39 -0800 (PST), Ray
> > Clark
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > Thanks Heath.
> > > > >
> > > > > I just had time again to get back to this. I
> > have
> > > > a
> > > > > new solution :)
> > > > >
> > > > > My renderer used to have this code:
> > > > >
> > > > > String colSpan = (String)
> > > > > rptTableCol.getAttributes().get("colSpan");
> > > > > if (colSpan != null) {
> > > > > writer.writeAttribute("colSpan",
> > colSpan,
> > > > null);
> > > > > }
> > > > >
> > > > > That code worked fine in JSF 1.1.01, but
> > didn't
> > > > work
> > > > > with myFaces 1.0.7. Well, I now have new code
> > in
> > > > the
> > > > > renderer that works. The renderer now looks
> > like
> > > > > this:
> > > > >
> > > > > ValueBinding vb =
> > > > > rptTableCol.getValueBinding("colSpan");
> > > > > String colSpan = null;
> > > > > if (vb == null) {
> > > > > colSpan = (String)
> > > > > rptTableCol.getAttributes().get("colSpan");
> > > > > } else {
> > > > > colSpan = (String)
> > vb.getValue(context);
> > > > > }
> > > > > if (colSpan != null) {
> > > > > writer.writeAttribute("colSpan",
> > colSpan,
> > > > null);
> > > > > }
> > > > >
> > > > > So to get this to work the renderer now has to
> > > > check
> > > > > to see if this attribute has value binding or
> > not.
> > > > > Then get the value appropriately. Now why
> > would
> > > > there
> > > > > be a difference between JSF 1.1.01 and
> > myFaces?
> > > > >
> > > > > Anyway, how does this solution look to you? :)
> > > > >
> > > > > Thanks,
> > > > > Ray
> > > > >
> > > > > --- Heath Borders <[EMAIL PROTECTED]>
> > wrote:
> > > > >
> > > > > > 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
> >
> === message truncated ===
>
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - Get yours free!
> http://my.yahoo.com
>
>
--
-Heath Borders-Wing
[EMAIL PROTECTED]