1

我有一个 JSF 页面,它只包含一个 PrimeFaces 日历组件,由一个视图范围的 bean 支持。

<p:calendar value="#{calendarBean.today}" mode="inline" showOtherMonths="true" pages="1" binding="#{calendarBean.model}" />

为这个组件生成的 HTML 包含一个我想调整的表格。更具体地说,我想通过在目标日期的 td-tags 下添加一些 HTML 代码来动态地将图标放入此日历中。

从 CalendarBean 中,我可以从某些服务中获取代表“带有图标”的天数的对象列表。我需要这个列表来决定在表格中更改哪些日期。我试图在我的支持 bean 中获取 HTML DOM,但我不明白如何。UIComponent 树(我通过绑定属性获得)仅包含 JSF 组件,而不包含生成的 HTML。我开始怀疑这是否是解决问题的方法。

我的谷歌技能似乎在这里不足。有谁能够帮我?

4

1 回答 1

1

The concrete functional requirement is not entirely clear, so it's hard to propose the right way for this, but there are in general varous ways to alter the look'n'feel of the JSF/PrimeFaces-generated HTML.

  1. Use custom CSS. Icons could simply be set as CSS background images.

  2. Use custom JS. JS has instant access to the entire HTML DOM tree.

  3. Use custom JSF renderer. Extend the PrimeFaces CalendarRenderer class and override the encodeXxx() method(s) accordingly.

The backing bean is supposed to be the controller between the view (the XHTML file) and the model (the javabean entity class holding the data which is to be presented to the enduser or to capture the submitted data from enduser). It isn't supposed to manipulate the HTML.

于 2012-11-12T13:23:47.933 回答