5

私はUIコンポーネントにprimefaceを使用しており、cssスタイルを使用してレイアウトユニットの背景を一時的に設定する必要があります.

 .layoutCustomStyle.ui-layout-unit-content
  {
     background-image: url('resources/images/backgrnd.png');
  }

layoutunit の ID は「layoutId」で、使用されるスタイルクラスは「layoutCustomStyle」です。

xhtmlで、

<p:layoutUnit position="top" id= "layoutId" styleClass ="layoutCustomStyle">
</p:layoutUnit>

しかし、私が望むのは、背景画像を動的に追加することです。画像はファイル ブラウザによって選択されるため、別のクラスを追加して Bean を使用することはできません。

UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
UIComponent comp= view.findComponent("layoutId");
Map<String, Object> attrMap = comp.getAttributes();
String className = (String)attrMap.get("styleClass");

これを使用して、クラス名を設定および取得できますが、属性「background-image:」を動的に変更するにはどうすればよいですか?

質問が明確であることを願っています。

前もってありがとう、ペガサス

4

2 に答える 2