title: how to add a css style property dynamically in JSF
body: <p>I am using primeface for the UI components and I have to set the background of the layout unit temporary its done by using the css style,</p>
  
  <pre><code> .layoutCustomStyle.ui-layout-unit-content
    {
       background-image: url('resources/images/backgrnd.png');
    }
  </code></pre>
  
  <p>The id of the layoutunit is "layoutId" and the styleclass used is "layoutCustomStyle"</p>
  
  <p>in xhtml,</p>
  
  <pre><code>&lt;p:layoutUnit position="top" id= "layoutId" styleClass ="layoutCustomStyle"&gt;
  &lt;/p:layoutUnit&gt;
  </code></pre>
  
  <p>But what I want is to add the background image dynamically. The image will be chosen by file browser so, I cannot add a separate class for that and use bean.</p>
  
  <pre><code>UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
  UIComponent comp= view.findComponent("layoutId");
  Map&lt;String, Object&gt; attrMap = comp.getAttributes();
  String className = (String)attrMap.get("styleClass");
  </code></pre>
  
  <p>using this I can set and get class names but how to change the attribute  "background-image:" dynamically?</p>
  
  <p>Hope the question is clear.Any help appreciated.</p>
  
  <p>Thanks in advance,
  Pegasus</p>