Show HTML formatting in Oracle ADF

Quick Tip- If you have html content stored in database in string and you want to display same html formatting in ADF.

Use escape attribute in outputText’s escape attribute.You can also try outputFormatted also.In outputFormatted there is no escape property.

     <af:outputText value="&lt;h2>&lt;b>Techartifact&lt;/b>&lt;/h2>" id="ot1"
                         escape="false"/>
          <af:outputFormatted value="&lt;h2>&lt;b>Techartifact&lt;/b>&lt;/h2>" id="of1"/>

and output wil be like below

blog

Happy learning with Vinay Kumar in techartifact.

Get value of the outputtext in javascript and access to backing bean in Oracle ADF

Requirement -Get value of the outputtext in javascript and send it to backing bean in Oracle ADF
Solution – We will use clientListener to call java script function and Serverlistener for calling java function

Below is the code for accomplish this

– page code

    <af:outputText value="value outputText" id="ot32" clientComponent="true"
                    shortDesc="shortDesc">
        <af:clientListener type="mouseOver"
                method="customJsFunction"/>
        <af:serverListener type="mycustomserverEvent" method="#{OutputTextCase11.handleServerEvent}"/>                
    </af:outputText>
    <br></br>
    <af:outputText value="Init" shortDesc="shortDesc" id="ot1" clientComponent="true"/>
 

– find javascript function code

   var customJsFunction = function(event)
   {
      var exceptiondata = event.getSource().findComponent("ot32").getValue();
      AdfCustomEvent.queue(event.getSource(),
                       "mycustomserverEvent",
                       {param1:exceptiondata},
                       true);
      return true;
   }
 

– method in bean

  public void handleServerEvent(ClientEvent ce)
  {
    String param = (String)ce.getParameters().get("param1");
    RichOutputText outputText=(RichOutputText)ce.getComponent().findComponent("ot1");
    outputText.setShortDesc(param);
    outputText.setValue(param);
    AdfFacesContext.getCurrentInstance().addPartialTarget(outputText);
  }
 

happy coding with Vinay in techartifact….

wraping text in outputText in Oracle ADF

Requirement- Wraping long text in outputText

Solutions- Many developer find solution to convert to input text and make read only.But that is just a work around.
Try this in inline Style – width:180px;display:inline-block;word-wrap:break-word
make nowrap property to false.

wrap


That’s it.

Happy coding with Vinay Kumar in techartifact….