• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to get Full Form Id?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a template in which I include jsp which has a radio button.
<h:selectOneRadio id="radioButton" onclick="callClick(this.form);">
this jsp has a <f:subview id = "listRadio"> From the Outermost jsp to the radio button jsp
I have subviews and forms in this order
<f:subview id ="list1">
<h:form id = "list2">
<f:subview id = "list3">
<f:subview id = "listRadio">

when I see the html source the element id of the radio is like "list1-list2-list3-listRadio-radioButton"
in the callClick js function if I try to get form.id I get only "list1-list2"

How can I get the full name with subview ids appended. I mean is there a way to get "list1-list2-list3-listRadio"
using form.id or any other attribute?
 
Saloon Keeper
Posts: 22133
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is, what do you want to do with it?

In JSF itself, the id is the simple ID as coded on the tag - for example "listRadio".

About the only time you need the full ID is when you're coding JavaScript, and as you've noted, the full ID can be determined by taking into account the simple ID plus its container IDs. The only really tricky part is to make sure that you're explicitly supplying container IDs instead of letting them be generated automatically, since generated IDs are unpredictable and likely to change without notice.
 
sdeepa redd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to disable/enable a button depending on the radiobutton is checked/unchecked.
So I use the form id in the javascript function. I have ids for all the containers explicity defined in code.
I can use the id of the button as "list1-list2-list3-listRadio-radioButton" in the js function to disable it but I wanted
to know if there is any way to get the full form id with all the subcontainer is("list1-list2-list3-listRadio")
using something like "form.id" or another type of js function?

Thanks.
 
Tim Holloway
Saloon Keeper
Posts: 22133
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This prompts for a value, but I've use similar code to enable/disable controls, too.

There is one caveat on disabling, however. Since it's managed BOTH by the raw http AND by JSF, it's possible to have the app get confused between client and server on whether the control is really disabled or not.

The safest way to handle that is to send an AJAX request as part of the disable operation with a reRender option on the control being disabled/enabled and to get the disablement stat from the backing bean. It's not as simple as doing everything client-side, but it's more reliable. The downside is that you have to use AJAX-capable tags such as those afforded by RichFaces.
 
Your buns are mine! But you can have this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic