dev@jsftemplating.java.net

Re: JSFTemplating: rendering component based on changing session attributes

From: Priti Tiwary <Priti.Tiwary_at_Sun.COM>
Date: Tue, 12 Sep 2006 11:04:35 -0700

Thanks Ken for the small working example. I will use this approach to
test small features which i have doubt about in future.
The reason of my code malfunctioning was that my alert had a not null
summary always. I observed that even when the rendered attribute was
false, it was getting rendered, because it found a summary. After
changing alerts summary to toggling values, i got the needed function
working.
Thanks a bunch, once again..
Priti

Ken Paulsen wrote:
>
> Hi Priti,
>
> Nothing appears to be wrong. I tested this (see attached file which
> you may run), and it works. The only difference is that I didn't have
> your "changeRenderProp" handler, so I simply used
> setSessionAttribute() to toggle it. In fact I added to buttons and
> was able to toggle back and forth successfully. I did this to a
> staticText also...
>
> I suspect your handler is not doing what you think it is doing.
>
> As for my opinions on this approach...
>
> * sun:alert automatically does this feature of you have or don't have
> a "summary" property. So in instead of toggling "rendered", you
> toggle "summary" from having a value to (null)... you'll get the same
> effect. I imagine you have to do this anyway?
>
> * I generally discourage the use of sessionScope in general. There
> are good cases for using it, but if you can do w/o out it... I
> recommend it. I have created the "pageSession" concept which may work
> well in this case (value is stored w/ the page instead of in
> session). requestScope will also often work in many cases (these
> values obviously don't stick around for multiple requests, though).
>
> Good luck!
>
> Kne
>
> Priti Tiwary wrote:
>> Hi,
>>
>> i have a qs related to rendering (lets say alert) component based on
>> attributes whose values are modified by other components(lets say
>> button).
>>
>> i have initially set render to false..so alert is not rendered when the
>> page is displayed first time..
>>
>> <!beforeCreate
>> setSessionAttribute(key="render", value="$boolean{false}")
>> />
>>
>> <sun:alert id="alert1" summary="Failed" details="check logs"
>> rendered="#{sessionScope.render}"/>
>> .....
>> <sun:button id="Btn1" text="Next">
>> <!command
>>
>> changeRenderProp(renderAlert=>$session{render})/>
>> </sun:button>
>>
>>
>> If changeRenderProp changes render value to true, after Next button
>> click, the same page should be displayed (navigate is doing that) but
>> with alert rendered..(not doing that right now)
>>
>> what is wrong here..?
>> Priti
>>
>>
> ------------------------------------------------------------------------
>
> <sun:page>
> <sun:html>
> <sun:head id="head" />
> <sun:body>
> <sun:form id="form">
> <sun:staticText value="StaticText Visible!" rendered="#{sessionScope.render}" />
> <sun:alert id="alert1" summary="Failed" details="check" rendered="#{sessionScope.render}" />
> <sun:button text="Show">
> <!command
> setSessionAttribute(
> key="render" value="$boolean{true}");
> />
> </sun:button>
> <sun:button text="Hide">
> <!command
> setSessionAttribute(
> key="render" value="$boolean{false}");
> />
> </sun:button>
> </sun:form>
> </sun:body>
> </sun:html>
> </sun:page>
>