0 Replies Latest reply on Mar 25, 2010 4:39 PM by Charleen Miguel

    OutputText loses styleClass on reRender

    Charleen Miguel Novice

      Hi -


      I have a form with a description field that needs to retain its style when a user toggles between edit mode and read mode.  The styleClass is called freeText, and it basically uses a fixed-width font and sets white-space: pre-wrap; so that it keeps the spacing in read mode.

      So, here is a snippet of my code:

      <a4j:commandLink action="#{bean.edit}" reRender="descPanel" value="Edit" rendered="#{bean.readMode}/>

      <a4j:commandLink action="#{bean.save}" value="Save" rendered="#{bean.editMode}"/>

      <a4j:commandLink action="#{bean.cancelEdit}" reRender="descpanel" value="Cancel" rendered="#{bean.editMode}"/>

      <h:panelGrid id="descPanel">

      <h:panelGroup id="editPanel" rendered="#{bean.editMode}">

        <h:inputTextarea styleClass="freeText" rows="15" cols="50" value="#{bean.description}" rendered="#{bean.editMode}"/>



      <h:panelGroup id="readPanel" rendered="#{bean.readMode}">

         <h:outputText styleClass="freeText" value="#{bean.description}" />




      When I first load the page, the freeText styleClass displays the outputText correctly.

      When I go into edit mode, the inputTextarea displays the text correctly.

      When I click the Cancel link and try to reRender the panel, the freeText styleClass is lost.

      However, if I click the Save link, which actually does a POST of the page, the freeText styleClass is recognized and the outputText area displays correctly.


      I can't seem to figure out why it is losing the styleClass.  I have even tried changing it to define the actual style attribute.  All of my other fields that don't use the "white-space: pre-wrap" style seem to work just fine.


      We are using Richfaces 3.3.1 and JSF 1.2.