You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-user@incubator.apache.org by Graeme Steyn <g....@cqu.edu.au> on 2007/01/17 02:04:46 UTC

Trinidad/Facelets problem with html elements being rendered repeatedly if there is a validation error - faces-1_2-070102 branch.

Good Morning again,
 
I have a another question related to the use of Trinidad and a problem
that I am experiencing.  I have basically got a mix of tomahawk,
facelets 1.1.11, Trinidad face-1_2-070102 branch, the reference JSF
implementation and Glassfish SJSAS 9_01 patch 1.  For the page in
question, I have surrounded the fields in a fieldset.  I have also used
the tr:form component, with a normal <body>.  When I submit the page
with an error that gets detected on the server side, it renders a
response with a blank fieldset for each of the fieldsets defined in the
page.  So for the original page in question there are 3 fieldsets.  The
page gets re-rendered with 3 empty fieldsets followed by the originals.
If you submit a second time with the same validation error, it gets
rendered with 6 empty fieldsets followed by the originals.  And so the
pattern continues.
 
Original Page
 
<fieldset1>
<fieldset2>
<fieldset3>
 
Rerendered Page - first submission error
 
<fieldset - empty>
<fieldset - empty>
<fieldset - empty>
<fieldset1>
<fieldset2>
<fieldset3>
 
Rerendered Page - second submission error
 
<fieldset - empty>
<fieldset - empty>
<fieldset - empty>
<fieldset - empty>
<fieldset - empty>
<fieldset - empty>
<fieldset1>
<fieldset2>
<fieldset3>
 
I have experienced a similar problem with the use of trh:body, where the
body contents get re-rendered multiple times.  Could anyone point me in
the right direction?  Is there an overview document that may deal with
some of the basic rules of using Trinidad that I could read.  For
example, covering things like the fact that Trinidad renders IDs
differently to the reference version of JSF.
 
The original page code appears below.
 
Thank you.

Graeme Steyn


 
quickDetails.xhtml
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:t="http://myfaces.apache.org/tomahawk"
  xmlns:tr="http://myfaces.apache.org/trinidad"  
  lang="en"
  xml:lang="en">
<head>
<meta
  http-equiv="Content-Type"
  content="text/html; charset=ISO-8859-1" />
<meta
  name="description"
  content="description" />
<meta
  name="keywords"
  content="keyword phrase1, keyword phrase 2, etc." />
<!-- <meta name="robots" content="noindex,nofollow" /> -->
<title>Quick Details</title>
<link
  rel="stylesheet"
  type="text/css"
  href="http://facultysite.cqu.edu.au/FCWViewer/css/styles.css" />
<link
  rel="stylesheet"
  type="text/css"
  href="http://facultysite.cqu.edu.au/FCWViewer/css/print.css"
  media="print" />
<link
  rel="stylesheet"
  type="text/css"
  href="http://facultysite.cqu.edu.au/FCWViewer/siteCSS.do?id=10" />
<link
  rel="stylesheet"
  type="text/css"
  href="../../stylesheets/online_app_styles.css" />
<link
  rel="stylesheet"
  type="text/css"
  href="http://facultysite.cqu.edu.au/FCWViewer/css/tab.css" />
<script
  type="text/javascript"
  src="http://facultysite.cqu.edu.au/FCWViewer/js/anylink.js"> </script>
<script
  type="text/javascript"
  src="http://facultysite.cqu.edu.au/FCWViewer/js/scripts.js"> </script>
<script
  type="text/javascript"
  src="http://facultysite.cqu.edu.au/FCWViewer/js/tabpane.js"> </script>
<script
  type="text/javascript"
  src="http://facultysite.cqu.edu.au/FCWViewer/js/jquery.js"> </script>
<script
  type="text/javascript"
  language="javascript"
  src="http://ibrainz.cqu.edu.au/player/player-js.php"> </script>
</head>
<body>
<f:view>
  <ui:composition template="/WEB-INF/templates/pageLayout.xhtml">
    <ui:define name="pageTitle">#{bundle.formQuickDetails}</ui:define>
    <ui:define name="content">
      <ui:decorate
template="/WEB-INF/templates/decoratorFormContent.xhtml">
        <ui:define
name="formTitle">#{bundle.formQuickDetails}</ui:define>
        <ui:define name="formContent">
 
          <tr:form id="quick">
    
            <fieldset>
              <legend> 
                <tr:outputText
                  value="#{bundle.fldSetPersonal}" /> 
              </legend> 
              
              <tr:panelFormLayout
                shortDesc="#{bundle.fldSetPersonal}">
    
                <tr:inputText
                  id="firstName"
                  label="#{bundle.bioGivenName}"
                  value="#{visit.candidate.firstName}"
                  shortDesc="#{bundle.bioGivenName}">
                  <f:validateLength maximum="17" />
                </tr:inputText>
      
                <tr:inputText
                  id="lastName"
                  label="#{bundle.bioLastName}"
                  value="#{visit.candidate.lastName}"
                  required="true"
                  shortDesc="#{bundle.bioLastName}">
                  <f:validateLength maximum="30" />
                </tr:inputText>
    
              </tr:panelFormLayout>
            
            </fieldset>
    
            <ui:include src="./compositions/contacts.xhtml" >
              <ui:param name="formReadOnly" value="false" />
            </ui:include>
 
            <ui:include src="./compositions/study.xhtml" >
              <ui:param name="formReadOnly" value="false" />
            </ui:include>
    
            <tr:separator />
    
            <tr:panelButtonBar id="pageNav">
              <tr:commandButton
                action="#{contact.previousAction}"
                text="#{bundle.btnBack}"
                shortDesc="#{bundle.btnBack}"
                immediate="true" />
              <ui:include src="./compositions/progressIndicator.xhtml"
/>
              <tr:commandButton
                action="#{contact.nextAction}"
                text="#{bundle.btnContinue}" 
                shortDesc="#{bundle.btnContinue}" />
            </tr:panelButtonBar>
    
          </tr:form>
        </ui:define> <!-- end "formContent" -->
      </ui:decorate>
    </ui:define> <!-- end "content" -->
  </ui:composition>
  <!-- end /WEB-INF/templates/pageLayout.xhtml -->
</f:view>
</body>
</html>

Facelets Template:
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:trh="http://myfaces.apache.org/trinidad/html"
      lang="en"
      xml:lang="en">
  <head>
    <trh:styleSheet />
    <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
    <meta name="description" content="description" />
    <meta name="keywords" content="keyword phrase1, keyword phrase 2,
etc." />
    <!-- <meta name="robots" content="noindex,nofollow" /> -->
    <title><ui:insert name="pageTitle">Default Title</ui:insert></title>
    <link rel="stylesheet" type="text/css"
href="http://facultysite.cqu.edu.au/FCWViewer/css/styles.css" />
    <link rel="stylesheet" type="text/css"
href="http://facultysite.cqu.edu.au/FCWViewer/css/print.css"
media="print"/>  
    <link rel="stylesheet" type="text/css"
href="http://facultysite.cqu.edu.au/FCWViewer/siteCSS.do?id=10" />
    <link rel="stylesheet" type="text/css"
href="#{facesContext.externalContext.requestContextPath}/stylesheets/onl
ine_app_styles.css"/>
    <link rel="stylesheet" type="text/css"
href="http://facultysite.cqu.edu.au/FCWViewer/css/tab.css" />
    <script type="text/javascript"
src="http://facultysite.cqu.edu.au/FCWViewer/js/anylink.js"> </script>
    <script type="text/javascript"
src="http://facultysite.cqu.edu.au/FCWViewer/js/scripts.js"> </script>  
    <script type="text/javascript"
src="http://facultysite.cqu.edu.au/FCWViewer/js/tabpane.js"> </script>
    <script type="text/javascript"
src="http://facultysite.cqu.edu.au/FCWViewer/js/jquery.js"> </script>
    <script type="text/javascript" language="javascript"
src="http://ibrainz.cqu.edu.au/player/player-js.php"> </script>
    <script type="text/javascript"
src="#{facesContext.externalContext.requestContextPath}/cscripts/help.js
"> </script>
  </head>
  <body>
    <f:view>
      <div id="wrap">
        <ui:insert name="header">
          <ui:include src="header.xhtml"/>
        </ui:insert>
        
        <div id="content">
          <ui:insert name="content">
            <div class="gutter">
              <p><strong>No page content has been provided.</strong></p>
            </div><!-- end gutter -->  
          </ui:insert>
          
          <ui:insert name="infoBarContent" />
          
        </div><!-- end content div -->
    
        <ui:insert name="footer">
          <ui:include src="footer.xhtml"/>  
        </ui:insert>
        
        <script src="http://www.google-analytics.com/urchin.js"
type="text/javascript"> </script>
  
      </div> <!-- end #wrap div-->
    </f:view>
  </body>
</html>
 
nextAction code:
 
    public boolean isPreferredChannelDataOk(FacesContext facesContext) {
 
        ContactType preferredChannel = getVisit().getCandidate()
                .getContacts().getPreferredContactType();
        String contactVal = getVisit().getCandidate().getContact(
                preferredChannel);
 
        if (contactVal == null || contactVal.equals("")) {
            FacesMessage message = new FacesMessage(
                    FacesMessage.SEVERITY_ERROR,
                    "A value must be entered.", null);
 
            // Note that to be able to display the error message with
the
            // correct field, a client ID is required. This means that
in
            // the xhtml, the ID for the fields must match the
toString()
            // values returned by the enumeration type. Note that
Trinidad
            // does not appear to prepend the field ID with the form ID
            // as done in the JSF standard. If using the core Html tags
(h)
            // you need to prepend the field ID with form ID.
            facesContext.addMessage(preferredChannel.toString(),
                    message);
            return false;
        }
 
        return true;
    }