开发者

How do I generate a unique ID for a DIV under JSF 1.2?

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 compo开发者_Python百科nents, 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.


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>.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜