• Post Reply Bookmark Topic Watch Topic
  • New Topic

component ID reference  RSS feed

 
Ekim Retrop
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - been using/looking into JSF for about 5 weeks. Hooking up a JSF app with tiles, pulled a couple things (tree2, jscookmenu) from myfaces; starting to know it well enough. Done some stuff with bundles, and see that its a bit cumbersome to use extensively.

The question is - can you refer to a component's attributes during its definition?

Here's a good example of what I mean

A typical outputText may look like this

<h utputText styleClass="outputText" id="journalSearchRegNumber" value="#{myBundle[journalSearchRegNumber]}"></h utputText>

So, you need to give the outputText an identifier, and then use some other identifier to get its label from a bundle. You probably want them to be one and the same, so you can readily identify them.

This seems like a lot of extra typing (ok - extra copy and pasting ;-) Plus, if you change the id of the component, you either change the reference into your bundle (and then the entry in the bundle, or you lose the link between the text in the bundle and which field uses it.

What I'm looking for is something like this:
<h utputText styleClass="outputText" id="journalSearchRegNumber" value="#{myBundle[#{id}]}"></h utputText>

(the syntax of the #{id} is purely fictitious)

When the HTML page is generated, the label is gathered from the bundle based on the id of the component - without you having to type it in twice.

I'm using RSA 6.0, websphere 6.0...beleive its just jsf 1.0

thanks
 
Ekim Retrop
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
d'oh! Sorry about that - that syntax isn't correct for accessing a bundle (that's what you get from typing from memory)

Still - can you somehow do this
<h utputText styleClass="outputText" id="journalSearchType" value="#{applicationBundle.${id}}"></h utputText>

rather than the fully specified way (ie
h utputText styleClass="outputText" id="journalSearchType" value="#{applicationBundle.journalSearchType}"></h utputText>

thanks
ciao
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!