webtier@glassfish.java.net

Re: [webtier] Question about Jim Driscoll's Ajax EditText Component Example

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Tue, 17 Feb 2009 15:42:09 -0800

All -

Ryan's been looking at this one, but I should let you know that the NPE
will happen if you have a "target" attribute that points to an id that
doesn't exist in the composite component.

So - to recap:

To use a method expression, you need to say:

<composite:attribute name="action" targets="navbutton" required="true"
method-signature="String f1(void)" />

where name is the attribute name on the containing tag, targets is the
list of IDs that the method will be acting against in the component
text, and method-signature is the anonymous signature of the method that
will be accepted.

If you instead have targets point to a non-existent id, you'll get an
NPE. That NPE was just fixed by Ryan, see bug #988.

Jim

On 2/8/09 10:00 PM, Lincoln Baxter, III wrote:
> I still get the NPE without the actionSource. I'll try to see if I can
> step debug more thoroughly. Last time it wouldn't let me step in to the
> execute() method.
>
>
> Caused by: java.lang.NullPointerException
> at java.io.Writer.write(Writer.java:140)
> at
> com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:193)
> at
> com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:120)
> at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:116)
> at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
>
>
>
> On Sun, 2009-02-08 at 10:06 -0800, Jim Driscoll wrote:
>> Well, I don't think we have a test that combines composite:actionSource
>> with composite:attribute method-signature, so you may have found a new
>> bug. If you remove the actionSource def, does it still fail?
>>
>> Jim
>>
>> On 2/8/09 9:30 AM, Lincoln Baxter, III wrote:
>> > Good call.
>> >
>> > My first thought is that I should probably get a more descriptive
>> > exception, even if I'm using it wrong.
>> > However, I get the same result :( This is what I did... irrelevant parts
>> > excluded.
>> >
>> > *Bean:*
>> >
>> > public void nameListener(final ActionEvent event)
>> > {
>> > System.out.println("Listened");
>> > }
>> >
>> >
>> > *Consumer:*
>> >
>> > <a:editText value="#{viewProjectBean.projectGoals}"
>> > submitListener="#{viewProjectBean.nameListener}" />
>> >
>> > *Component:*
>> >
>> > <composite:interface name="editText"
>> > displayName="Editable Text Component"
>> > shortDescription="Editable Text Component">
>> > <composite:attribute name="submitListener" targets="submit"
>> > required="true"
>> > method-signature="void f1(javax.faces.event.ActionEvent)" />
>> > <composite:attribute name="value" required="true" type="String" />
>> > <composite:actionSource name="submit" />
>> > </composite:interface>
>> >
>> > <composite:implementation>
>> > .....
>> > <h:commandButton value="Submit" id="submit"
>> > actionListener="#{compositeComponent.attrs.submitListener}"
>> > onclick="return submitButton('#{compositeComponent.clientId}',
>> > event);">
>> > </h:commandButton>
>> > <h:commandButton value="Cancel" id="cancel" styleClass="faded"
>> > onclick="return cancelButton('#{compositeComponent.clientId}');" />
>> > ....
>> > </composite:implementation>
>> >
>> > </html>
>> >
>> >
>> >
>> > On Sun, 2009-02-08 at 08:56 -0800, Jim Driscoll wrote:
>> >>
>> >> To see how to call a listener in a component, see here:
>> >>
>> >> http://weblogs.java.net/blog/driscoll/archive/2008/12/jsf_20_wiring_u_1.html
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:webtier-unsubscribe_at_glassfish.dev.java.net <mailto:webtier-unsubscribe_at_glassfish.dev.java.net>
>> For additional commands, e-mail:webtier-help_at_glassfish.dev.java.net <mailto:webtier-help_at_glassfish.dev.java.net>
>>