| Author |
Can i get component attribute values inside the component
|
Itzik Peretz
Greenhorn
Joined: Mar 01, 2010
Posts: 3
|
|
Hi,
I have some components of inputText and i want to use the id or the value of the component as a value to other attribute (see the bold part)
<h:inputText id="bsmDNSSearch" value="${(installConfig.bsmDNSSearchDefined) ? installConfig.bsmDNSSearch : this.value}"
disabled="#{installConfig.doNotInstallSMAsBool}" />
Is it possible? In General how can you reference to the component attributes inside the component?
Thanks,
Itzik
|
 |
Christian Nicoll
Ranch Hand
Joined: Mar 09, 2008
Posts: 106
|
|
In General how can you reference to the component attributes inside the component?
If you build a custom component then this is usually extended from UIComponent class. UIComponent provides a method getAttributes() which gives you a map that represents all your attributes:
http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/api/javax/faces/component/UIComponent.html
|
SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
|
 |
Itzik Peretz
Greenhorn
Joined: Mar 01, 2010
Posts: 3
|
|
Hi,
I know how to get any attribute in the server side. can I refer to it in the client side?
Itzik
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Your value won't work because an inputText control's value expression must be an lvalue. That means if you can't place the value of the left-hand side (before the "=") of an assignment statement, it's not valid.
You can obtain (and modify) the values of the core JSF controls on the client's browser using client-side code, since the default HTML renderer converts them into ordinary HTML controls. However, accessing them is a little more complicated that accessing straight HTML, since the id attributes of the generated HTML isn't the exact same value as the id you code on the JSF. The generated HTML ids are composites of the JSF ID plus the IDs of the containers that surround it such as the h:form object.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Itzik Peretz
Greenhorn
Joined: Mar 01, 2010
Posts: 3
|
|
|
Thanks for the help, that what i thought, I just wanted to be sure.
|
 |
 |
|
|
subject: Can i get component attribute values inside the component
|
|
|