cancel
Showing results for 
Search instead for 
Did you mean: 

Developing forms for ME: Styling an outputLabel ... JSF version 2.2?

Former Member
0 Kudos

I'm working on a custom activity for SAP ME.  My basic requirement is to 'gray out' the label under certain circumstances determined by the logic in the Controller class. My view contains "fh:outputLabel" elements (taglib prefix="fh" uri=http://java.sun.com/jsf/html).  I would like to put an EL expression into the styleClass attribute.  This would be the example:

<fh:outputLabel value="#{gapiI18nTransformer['NONPOD_INVTRANSFER.transqty.LABEL']}"

      styleClass="#{inventoryTransferBean.transQtyLabelStyle}" />

From a bit of exploration of the JSF documentation, it appears that JSF 2.2 allows this, while JSF 1.1 does not.  In fact, when I try it, the entire page disappears.  Nothing even appears in View Source.

Any suggestions?

Thanks,

Barry

Accepted Solutions (1)

Accepted Solutions (1)

former_member185234
Active Participant
0 Kudos

Hello Barry ,

I have added label to jsp inside form with id = "materialCustomDataForm" :

<fh:outputLabel  id="LABEL_ID" value="Label" />     

Then I found component by id , logic in controller class :

HtmlOutputLabel labelID = (HtmlOutputLabel) findComponent(FacesUtility.getFacesContext().getViewRoot(), "materialCustomDataForm:LABEL_ID");

Then I defined style to label :
labelID.setStyle("color:#0000AA;font-weight:bold;font-size:20pt;");
 
Then I should refresh panel with this label :
UIComponent fieldButtonPanel = findComponent(FacesUtility.getFacesContext().getViewRoot(),"materialCustomDataForm:fieldButtonPanel");
if (fieldButtonPanel != null) {
  FacesUtility.addControlUpdate(fieldButtonPanel);
}


Thanks,
Oksana

Former Member
0 Kudos

Oksana,

Thank you!  I think I can use this.

The 'procedural' approach is a bit more code, so if there is a more 'declarative' solution, I would still be interested to hear about it (from anyone).

I would also be interested to hear if anyone has seen a similar 'error behavior' -- where a small change in an attribute causes the whole page to go blank.

Barry

Answers (0)