5 Replies Latest reply on Jul 28, 2010 7:22 AM by christophe delarue

    Default value for inputText and inputTextarea

    christophe delarue Newbie


      This is maybe a newbie question, but I can't figure out how to deal with that.

      I've got this inputTextarea (home.xhtml)

      <h:inputTextarea required="true" id="xml" rows="10" cols="80"
                                   value="#{XPathExtractor.xml}" />

      The Seam component

      public class XPathExtractor
          /** The xml string to parse */
          private String xml;

      I d like at first open of the file home.seam to get a default value for the xml field.
      I set the required default content in messages_fr.properties

      sample = <xml>sample</xml>

      If I code

          public XPathExtractor ()

      A have the text #{messages.sample} in the text area instead of <xml>sample</xml>

      If I set

      <h:inputTextarea required="true" id="xml" rows="10" cols="80" 
                      value="#{not empty XPathExtractor.xml ? XPathExtractor.xml : messages.sample}" /> 

      This produces exception.

      IMO, the defaut value should be set outside of the java code (ie not in the contrusctor XPathExtractor ()), but I can't figure how.

      Thank's for help