Hi

Add the resource in afterPhase(...) is too late in the lifecycle, because
if the response was flushed the script could not be rendered. Add it in
beforePhase(...)  of render response should work.

Just FYI, ExtensionsFilter class is the one responsible to create the
buffer and then parse the response and insert the code.

The API was meant to be used in components, but I do not see any reason why
it should not work. It could be an old bug that was fixed at some point in
time.

regards,

Leonardo Uribe

2016-04-19 14:14 GMT-05:00 Mike Kienenberger <mkien...@gmail.com>:

> I guess it probably doesn't help -- it looks like your phase listener
> was already using RENDER_RESPONSE.
>
> On Tue, Apr 19, 2016 at 3:13 PM, Mike Kienenberger <mkien...@gmail.com>
> wrote:
> > There is only a RENDER_RESPONSE phase for the initial request in a
> > phase listener, but all of the phases in a postback.
> >
> > Does that help?
> >
> >
> > On Tue, Apr 19, 2016 at 2:09 PM, fischman_98
> > <mfisc...@powerconsultantsinc.com> wrote:
> >> *FYI*: When added the call to addResource in encodeEnd method of a
> Custom
> >> Component it works on both /*initial request*/ and /*postback */.
> >>
> >> Here's the initial request;
> >>
> >> RESTORE_VIEW(1) :: Before
> >> RESTORE_VIEW(1) :: After
> >> RENDER_RESPONSE(6) :: Before
> >> *AddResource Here!*
> >> RENDER_RESPONSE(6) :: After
> >>
> >> Same code I had in the listener in the encodeEnd;
> >>
> >>         AddResource ar = AddResourceFactory.getInstance(facesContext);
> >>         ar.addInlineScriptAtPosition(facesContext,
> AddResource.HEADER_BEGIN,
> >> "window.open()");
> >>         System.out.println("AddResource Here!");
> >>
> >> So....any thoughts why it works from the component and not from the
> phase
> >> listener?
> >>
> >> Thanks.
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> http://myfaces.10567.n7.nabble.com/addResource-to-add-CSS-JS-Only-working-on-PostBack-tp121593p121619.html
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>

Reply via email to