Hi Karam,
All EL and handler code is executed on the server before the page is
rendered, or in some cases in response to a submission to the server.
So getting the content to show up in a text field via any EL expression
after the page is already on the client will not work.
Using an Ajax approach, you could send the selection to the server and
cause the textField to be updated... this would achieve what you want
and allow you to track the value via a pageSession attribute.
Using a JavaScript-only approach, you should obtain the value (like you
did below), then set the value on the static text (which I believe is
enclosed in a <span> tag).
If you know the "id" of the HTML element that you want to find, you can
obtain that element by doing the following JavaScript:
var menu = document.getElementById("form:lavaRelaseMenu");
Then you could write:
var value = menu.options[menu.selectedIndex].value;
And then find the span to update (you may need to provide an id for it):
var text = document.getElementById("form:text");
text.innerHTML = "<b>You selected: " + value + "</b>";
I didn't verify that what I wrote is syntatically correct, so I may have
made errors... but I think you get the point. There are other ways to
replace the HTML as well. innerHTML allows you to add other HTML
elements (such as <b> tags) inside it... not sure if other ways allow
that as easily.
I hope this helps,
Ken
Karam Singh Badesha wrote:
> Ok, I can get it using from javascript using:
>
> document.form1.lavaReleaseMenu.options[document.form1.lavaReleaseMenu.selectedIndex].value
>
>
> But how do I really specify this in a value attribute to create a
> pageSession variable out of this?
>
> <sun:staticText value="#{pageSession.lavaRelease}" >
> <!beforeEncode
> setPageSessionAttribute(key="lavaRelease" value="?");
> />
>
> thanks
> Karam
>
> Karam Singh Badesha wrote:
>> Hi,
>> Here is the scenario:
>> In my page, I get the values for my dropdowns using the beforeCreate:
>>
>> <!beforeCreate
>> getReleases(lavaReleases=>$attribute{lavaReleasesList});
>> getBuilds(lavaBuilds=>$attribute{lavaBuildsList});
>> getProjects(lavaProjects=>$attribute{lavaProjectsList});
>> />
>>
>> Now at some where on the page I show these dropdowns and I have the
>> following to fill the dropDowns:
>>
>> <sun:dropDown id="lavaReleaseMenu"
>> toolTip="#{msgs.chooseLavaRelease}"
>> labels="$attribute{lavaReleasesList}"
>> />
>>
>> Now I would like to show the selected items in those dropDowns at
>> another part of the page. How would I get the selected value at
>> render time so that I can also show it at the later point on the same
>> page? I vaguely remember that in javascript you could get it by doing
>> something like form1.lavaReleaseMenu. How can I take care of this
>> situation?
>>
>> thanks
>> Karam