This is a very good use of page session. It doesn't live too long, and
you don't have to manage it each request. Using #{pageSession.key} or
#{key} syntax (as opposed to $pageSession{key}) is also significant here
as the selected value may change. Values expressed with ${} syntax are
evaluated by factories only 1 time per page (UIComponents are only
created 1 time); #{} expressions will ensure the value is processed
every time the page is rendered and re-rendered.
Ken
Jennifer Chou wrote:
> Thanks for the example! So here you get the selected value from the
> handler and store in a page session attribute. I probably need to do
> something like this too. I will try it out.
>
> Thanks,
> Jennifer
>
> Anissa Lam wrote:
>> Hi Jennifer,
>>
>> I believe you can something like the following.
>> The idea is get the list before create so you can pass that to the
>> dropdown factory. If your dropdown's label and value is different,
>> you can also pass in the "values" during creation. You probably want
>> to do the binding for the selected value.
>>
>> <sun:property id="resAdapterProp"
>> label="$resource{i18n.common.resourceAdapter}" >
>> <sun:dropDown id="dd" selected="#{selectedAdapter}"
>> labels="$attribute{adapterList}" required="#{true}">
>> <!beforeCreate
>>
>> getAdapterListAndDefaultValue(selectedAdatper=>$pageSession{selectedAdapter}
>> adapterList=>$attribute{adapterList} );
>> />
>> </sun:dropDown>
>> </sun:property>
>>
>>
>> @Handler(id="getAdapterListAndDefaultValue",
>> output={
>> @HandlerOut(name="selectedAdapter" type="String.class"),
>> @HandlerOutput(name="adapterList", type=java.util.List.class)}
>> )
>>
>> Call me if you have any questions. I can also show you the code.
>>
>> Anissa.
>>
>> Jennifer Chou wrote:
>>> Hi,
>>>
>>> I am wondering what is the best way to have a default option in a
>>> drop-down already selected when you go to a page. Right now none is
>>> selected. In the old admin gui I called a handler
>>> setDropDownOptionsAndDefaultValue which did this for me. I want to
>>> use the selected 'Server' value to show to show the appropriate web
>>> service messages/statistics when you go to the page before user has
>>> made a selection.
>>>
>>> Thanks,
>>> Jennifer
>>
>