• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can i get component attribute values inside the component

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Itzik Peretz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I know how to get any attribute in the server side. can I refer to it in the client side?

Itzik
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Itzik Peretz
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help, that what i thought, I just wanted to be sure.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic