从 bean 追加 CSS 样式
Append CSS style from a bean
是否可以在组件的 @PostConstruct 期间附加样式,例如附加到命令按钮。更改样式 class 这里没办法,因为我需要动态值。
我尝试了以下重置按钮样式的方法
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
CommandButton button = (CommandButton)root.findComponent("form:btn1");
button.setStyle("background-color: red;");
您可以使用表达式语言动态地为 commandButton
分配样式:
<p:commandButton ... style="#{bean.buttonStyle}" ... />
是否可以在组件的 @PostConstruct 期间附加样式,例如附加到命令按钮。更改样式 class 这里没办法,因为我需要动态值。
我尝试了以下重置按钮样式的方法
UIViewRoot root = FacesContext.getCurrentInstance().getViewRoot();
CommandButton button = (CommandButton)root.findComponent("form:btn1");
button.setStyle("background-color: red;");
您可以使用表达式语言动态地为 commandButton
分配样式:
<p:commandButton ... style="#{bean.buttonStyle}" ... />