Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to identify an element in a Panel Series? (or a standard jsf list for that matter)  RSS feed

 
Ong CherYee
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I would like to know how to get the id of a specific outputLink in a Panel Series? (Not the panel series itself but the individual link which the user clicks on)
The context is that a word cloud is displayed and when a user clicks on a text (which is an output link) in the word cloud, a search operation based on that text is launched.

I would like to use getElementById in a javascript function to get the value of the specific outputLink based on its id.

Alternatively, is there a way to pass the value of the outputLink to the javascript function?
I had tried this.value as arguments to the launchSearch function but the result is always undefined. I had also tried passing this.id as an argument then use getElementById to read the value but the result is also undefined.

Attached is the code:





I've been stuck at this for some time and it's driving me crazy. :banghead:
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know much about icefaces but you haven't given your link an (html) id so what do you intend to get? Why not call the method passing in the generated html dom element by using 'this'

 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"this" is my first choice as well, and not just for JSF. It has the advantage of not only being independent of the structure and platform of the web page, but also of providing direct access to the object itself and all of its attributes. And without the overhead of a DOM search.

JSF operates on what are known as naming containers. Certain types of elements are naming containers, among them being h:form, h:dataTable, h:panelGrid. When JSF converts an element ID to its HTML id, the HTML ID is a concatenation of the names of the parent naming containers to the simple id. So that for example, id="inputSSN" on the third row of table t1 in form1 would have an ID of "form1:t1:2:inputSSN". At least if I didn't lose anything. Row numbering, incidentally, starts at 0, which is why the third row has an ID of 2.

For any naming container (or base-level) objects not supplied with explicit IDs, JSF will synthesize an ID. So an unnamed table would result in something like "form1:j_131:0:inputSSN". It's usually better to supply an explicit ID, as the synthesized IDs are unpredictable, can change without notice, and a real pain to debug.

So, in short, what I recommend is to use "this", but if you have a situation that doesn't make that feasible, now you know the rules that JSF will use.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!