File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes assign a defined Id to all the tags in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "assign a defined Id to all the tags in JSF" Watch "assign a defined Id to all the tags in JSF" New topic
Author

assign a defined Id to all the tags in JSF

sree javab
Greenhorn

Joined: May 05, 2008
Posts: 9
I am a newbie to JSF and have been trying the below,

I have 10 rows in a JSF page, and 10 rows are of the same tag type, say <tr:image>. I wanted to assign an Id to each image tag in a specified format say,

<tr:image id="image_1" source="/img/icon/delete.png" />
<tr:image id="image_2" source="/img/icon/delete.png" />
<tr:image id="image_3" source="/img/icon/delete.png" />
.
.
.
<tr:image id="image_10" source="/img/icon/delete.png" />

Can some one please help me in this case.
Thanks in advance.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Then just do that so?

If you actually have a problem with doing that, then please elaborate about it in detail.
sree javab
Greenhorn

Joined: May 05, 2008
Posts: 9
<tr:image id="image_1" source="/img/icon/delete.png" />
<tr:image id="image_2" source="/img/icon/delete.png" />
<tr:image id="image_3" source="/img/icon/delete.png" />
.
.
.
<tr:image id="image_10" source="/img/icon/delete.png" />


Firstly I do not know how many rows of <tr:image /> will be there...and I wanted to append image_1,_2,_3...._10....my question is how do I generate that increasing number in JSF, and assign that to 'id' attribute?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Oh, you have only one tr:image component inside some UIData component (a table or so)? Why did you mention that you have more tr:image components? Did you check the HTML output, do you see more <tr:image> elements? No, you just see more <img> elements.

No, that's not possible. Just assign it a fixed ID to it. JSF will prepend the row ID to it automatically.

Why this question? Are you just facing a problem for which you think that fixing the ID is the solution? In the future it will be more helpful if you just elaborate about the actual problem instead of asking how to achieve something of which you think that it is the right solution (which may not be a right solution at all, as you see now).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: assign a defined Id to all the tags in JSF