Saturday, January 16, 2016

Change the Color of Prompt and Value of Text field in OAF

In this blog, I try to handle a scenario where we need to set the color of Prompt and Value of a text field in an OAF page.
We will not be able to set the CSS for the text in the prompt of a messageTextInput field. I am sharing a workaround here for that.
We create a rowLayout and two cellFormats with in it. The first cellFormat will have a staticStyledText which holds the Prompt text and the second cellFormat will have a messageTextInput field which holds the Value.

Page XML Code
<oa:header id="TestPromptColRN">  
   <ui:contents>  
   <oa:rowLayout id="RL">  
   <ui:contents>  
   <oa:cellFormat id="Cell1">  
      <ui:contents>  
      <oa:staticStyledText id="SST1" text="PO Number" prompt="PO Number"/>  
      </ui:contents>  
   </oa:cellFormat>  
   <oa:cellFormat id="Cell11">  
      <ui:contents>  
      <oa:messageTextInput id="MTI1"/>  
      </ui:contents>  
   </oa:cellFormat>  
   </ui:contents>  
   </oa:rowLayout>  
   </ui:contents>  
</oa:header>  


Java code to be placed in the processRequest of the Page's Controller.
CSSStyle customCss = new CSSStyle();  
customCss.setProperty("color", "#FF0000");  
OAStaticStyledTextBean sstBean =   
    (OAStaticStyledTextBean)webBean.findChildRecursive("SST1");  
if (sstBean != null)  
    sstBean.setInlineStyle(customCss);  
OAMessageTextInputBean mtiBean =   
    (OAMessageTextInputBean)webBean.findChildRecursive("MTI1");  
if (mtiBean != null)  
    mtiBean.setInlineStyle(customCss); 


The output will be like.



No comments:

Post a Comment