1

I need a unique id for some DIVs under JSF 1.2, how do I go about doing this in a manner that can be resolved later for use in a Javascript function?

Traditionally I use either JSF HTML or Richfaces components, which automatically use JSF to generate an unique id and then use rich:clientId() to resolve that id. I just haven't found a component that will just give me a DIV.

James McMahon
  • 48,506
  • 64
  • 207
  • 283

3 Answers3

3

The <h:panelGroup layout="block"> will render a <div>.

When the layout attribute is omitted and when it has another attributes which should end up in HTML, like styleClass and so on, it will by default render a <span>.

James McMahon
  • 48,506
  • 64
  • 207
  • 283
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
2

You can render a div as discussed in this question, What jsf component can render a div tag?

Community
  • 1
  • 1
Giorgos Dimtsas
  • 12,019
  • 3
  • 29
  • 40
2

BalusC is partially correct about <h:panelGroup layout="block"> producing a div, thought strangely enough you need to include a style or styleClass element to guarantee that it produces a div. Here is the quote from the documentation.

If the "style" or "styleClass" attributes are present, and the "layout" attribute is present with a value of "block", render a "div" element

When you put an ID on the h:panelGroup then it will be prepending with a JSF id. This doesn't work on JSF Facelets however, where you will run into duplicate ID issues.

James McMahon
  • 48,506
  • 64
  • 207
  • 283