myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject cvs commit: incubator-myfaces/webapps/examples/web/inc navigation.jsp
Date Mon, 10 Jan 2005 08:08:22 GMT
matzew      2005/01/10 00:08:22

  Modified:    src/share/org/apache/myfaces/renderkit JSFAttr.java
               tlds/entities ui_component_attributes.xml
               src/share/org/apache/myfaces/taglib
                        UIComponentBodyTagBase.java UIComponentTagBase.java
               src/components/org/apache/myfaces/component/html/ext
                        HtmlInputText.java
               webapps/examples/src/org/apache/myfaces/examples/resource
                        example_messages_es.properties
                        example_messages_ca.properties
                        example_messages_fr.properties
                        example_messages_pt_BR.properties
                        example_messages_ja.properties
                        example_messages_de.properties
                        example_messages.properties
               webapps/examples/web/WEB-INF examples-config.xml
               webapps/examples/web/inc navigation.jsp
  Added:       webapps/examples/src/org/apache/myfaces/examples/misc
                        ForceIdBean.java
               webapps/examples/web forceId.jsp
               src/components/org/apache/myfaces/component/html/util
                        HtmlComponentUtils.java
  Log:
  added patch form sean schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
  
  Revision  Changes    Path
  1.6       +4 -3      incubator-myfaces/src/share/org/apache/myfaces/renderkit/JSFAttr.java
  
  Index: JSFAttr.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/renderkit/JSFAttr.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JSFAttr.java	13 Oct 2004 11:51:01 -0000	1.5
  +++ JSFAttr.java	10 Jan 2005 08:08:11 -0000	1.6
  @@ -32,7 +32,8 @@
       public static final String   STYLE_CLASS_ATTR               = "styleClass";
       public static final String   ESCAPE_ATTR                    = "escape";
       public static final String   TRANSIENT_ATTR                 = "transient";
  -
  +    public static final String   FORCE_ID_ATTR                  = "forceId";
  +    
       // Common Output Attributes
       public static final String   FOR_ATTR                       = "for";
       public static final String   CONVERTER_ATTR                 = "converter";
  
  
  
  1.13      +8 -0      incubator-myfaces/tlds/entities/ui_component_attributes.xml
  
  Index: ui_component_attributes.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/tlds/entities/ui_component_attributes.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ui_component_attributes.xml	5 Apr 2004 11:04:56 -0000	1.12
  +++ ui_component_attributes.xml	10 Jan 2005 08:08:11 -0000	1.13
  @@ -31,3 +31,11 @@
               <type>java.lang.String</type>
               <description>If true, this component will not be saved during state saving.</description>
           </attribute>
  +
  +        <attribute>
  +            <name>forceId</name>
  +            <required>false</required>
  +            <rtexprvalue>false</rtexprvalue>
  +            <type>java.lang.String</type>
  +            <description>If true, this component will force the use of the specified
id when rendering.</description>
  +        </attribute>        
  \ No newline at end of file
  
  
  
  1.11      +12 -2     incubator-myfaces/src/share/org/apache/myfaces/taglib/UIComponentBodyTagBase.java
  
  Index: UIComponentBodyTagBase.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/taglib/UIComponentBodyTagBase.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- UIComponentBodyTagBase.java	13 Oct 2004 11:51:01 -0000	1.10
  +++ UIComponentBodyTagBase.java	10 Jan 2005 08:08:12 -0000	1.11
  @@ -31,6 +31,9 @@
    * @author Manfred Geiler (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.11  2005/01/10 08:08:12  matzew
  + * added patch form sean schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
  + *
    * Revision 1.10  2004/10/13 11:51:01  matze
    * renamed packages to org.apache
    *
  @@ -116,6 +119,7 @@
   
       //UIComponent attributes
       private String _transient;
  +    private String _forceId;
   
       //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
       private String _value;
  @@ -127,6 +131,7 @@
           super.setProperties(component);
   
           setBooleanProperty(component, JSFAttr.TRANSIENT_ATTR, _transient);
  +        setBooleanProperty(component, JSFAttr.FORCE_ID_ATTR, _forceId);
   
           //rendererType already handled by UIComponentTag
   
  @@ -137,6 +142,11 @@
       public void setTransient(String aTransient)
       {
           _transient = aTransient;
  +    }
  +    
  +    public void setForceId(String aForceId)
  +    {
  +        _forceId = aForceId;
       }
   
       public void setValue(String value)
  
  
  
  1.8       +13 -3     incubator-myfaces/src/share/org/apache/myfaces/taglib/UIComponentTagBase.java
  
  Index: UIComponentTagBase.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/share/org/apache/myfaces/taglib/UIComponentTagBase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- UIComponentTagBase.java	13 Oct 2004 11:51:01 -0000	1.7
  +++ UIComponentTagBase.java	10 Jan 2005 08:08:12 -0000	1.8
  @@ -24,6 +24,9 @@
    * @author Manfred Geiler (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.8  2005/01/10 08:08:12  matzew
  + * added patch form sean schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
  + *
    * Revision 1.7  2004/10/13 11:51:01  matze
    * renamed packages to org.apache
    *
  @@ -50,7 +53,8 @@
   
       //UIComponent attributes
       private String _transient;
  -
  +    private String _forceId;
  +    
       //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
       private String _value;
       private String _converter;
  @@ -61,6 +65,7 @@
           super.setProperties(component);
   
           setBooleanProperty(component, JSFAttr.TRANSIENT_ATTR, _transient);
  +        setBooleanProperty(component, JSFAttr.FORCE_ID_ATTR, _forceId);
   
           //rendererType already handled by UIComponentTag
   
  @@ -71,6 +76,11 @@
       public void setTransient(String aTransient)
       {
           _transient = aTransient;
  +    }
  +    
  +    public void setForceId(String aForceId)
  +    {
  +        _forceId = aForceId;
       }
   
       public void setValue(String value)
  
  
  
  1.5       +18 -2     incubator-myfaces/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java
  
  Index: HtmlInputText.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/component/html/ext/HtmlInputText.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HtmlInputText.java	13 Oct 2004 11:50:56 -0000	1.4
  +++ HtmlInputText.java	10 Jan 2005 08:08:14 -0000	1.5
  @@ -17,6 +17,7 @@
   
   import org.apache.myfaces.component.UserRoleAware;
   import org.apache.myfaces.component.UserRoleUtils;
  +import org.apache.myfaces.component.html.util.HtmlComponentUtils;
   
   import javax.faces.context.FacesContext;
   import javax.faces.el.ValueBinding;
  @@ -25,6 +26,9 @@
    * @author Manfred Geiler (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.5  2005/01/10 08:08:14  matzew
  + * added patch form sean schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
  + *
    * Revision 1.4  2004/10/13 11:50:56  matze
    * renamed packages to org.apache
    *
  @@ -42,6 +46,18 @@
           extends javax.faces.component.html.HtmlInputText
           implements UserRoleAware
   {
  +        
  +    private String clientId;
  +    
  +    public String getClientId(FacesContext context)
  +    {
  +        if (clientId == null) 
  +        {
  +            clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
  +        }
  +        return clientId;
  +    }
  +    
       //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
   
       public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlInputText";
  
  
  
  1.1                  incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/misc/ForceIdBean.java
  
  Index: ForceIdBean.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.myfaces.examples.misc;
  
  /**
   * @author <a href="mailto:matzew@apache.org">Matthias Weßendorf</a> 
   */
  public class ForceIdBean {
      
      private String valueOne, valueTwo;
  
      public String getValueOne() {
          return valueOne;
      }
      public void setValueOne(String valueOne) {
          this.valueOne = valueOne;
      }
      public String getValueTwo() {
          return valueTwo;
      }
      public void setValueTwo(String valueTwo) {
          this.valueTwo = valueTwo;
      }
  }
  
  
  
  1.5       +6 -1      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_es.properties
  
  Index: example_messages_es.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_es.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- example_messages_es.properties	9 Jan 2005 12:36:58 -0000	1.4
  +++ example_messages_es.properties	10 Jan 2005 08:08:14 -0000	1.5
  @@ -33,6 +33,8 @@
   nav_css             = Hoja de estilos
   nav_newspaperTable  = Tabla de Noticias
   nav_HtmlEditor		= Editor Html
  +nav_forceId         = ForceId
  +
   nav_swapimage       = SwapImage
   # buttons
   
  @@ -154,4 +156,7 @@
   js_popup=Calendario como un popup JavaScript.
   js_form=Calendario como un formulario.
   js_submit=Enviar
  -css_msg=Una prueba simple para 
  \ No newline at end of file
  +css_msg=Una prueba simple para 
  +
  +forceOne=Value 1 @TRANSLATE
  +forceTwo=Value 2 (with forceId) @TRANSLATE
  \ No newline at end of file
  
  
  
  1.5       +6 -1      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_ca.properties
  
  Index: example_messages_ca.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_ca.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- example_messages_ca.properties	9 Jan 2005 12:36:58 -0000	1.4
  +++ example_messages_ca.properties	10 Jan 2005 08:08:14 -0000	1.5
  @@ -33,6 +33,8 @@
   nav_css             = Full d'estils 
   nav_newspaperTable  = Taula de notícies
   nav_HtmlEditor		= Editor Html
  +nav_forceId         = ForceId
  +
   nav_swapimage       = SwapImage
   # buttons
   
  @@ -154,4 +156,7 @@
   js_popup=Calendari com un popup JavaScript.
   js_form=Calendari com un formulari.
   js_submit=Enviar
  -css_msg=Una prova simple per  
  \ No newline at end of file
  +css_msg=Una prova simple per  
  +
  +forceOne=Value 1 @TRANSLATE
  +forceTwo=Value 2 (with forceId) @TRANSLATE
  \ No newline at end of file
  
  
  
  1.11      +5 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_fr.properties
  
  Index: example_messages_fr.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_fr.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- example_messages_fr.properties	9 Jan 2005 12:36:58 -0000	1.10
  +++ example_messages_fr.properties	10 Jan 2005 08:08:14 -0000	1.11
  @@ -29,8 +29,10 @@
   nav_Date			= Date
   nav_css             = Stylesheet
   nav_newspaperTable  = Newspaper Table
  +nav_forceId         = ForceId
   nav_swapimage       = SwapImage
   
  +
   # buttons
   
   button_save = Sauvegarder
  @@ -100,3 +102,6 @@
   validate_regexp = Regular Expression
   validate_equal = Equal
   validate_isbn = ISBN
  +
  +forceOne=Value 1 @TRANSLATE
  +forceTwo=Value 2 (with forceId) @TRANSLATE
  \ No newline at end of file
  
  
  
  1.5       +5 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_pt_BR.properties
  
  Index: example_messages_pt_BR.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_pt_BR.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- example_messages_pt_BR.properties	9 Jan 2005 12:36:58 -0000	1.4
  +++ example_messages_pt_BR.properties	10 Jan 2005 08:08:14 -0000	1.5
  @@ -31,7 +31,9 @@
   nav_panelstack      = Panel Stack
   nav_css             = Stylesheet
   nav_newspaperTable  = Newspaper Table
  +nav_forceId         = ForceId
   nav_swapimage       = SwapImage
  +nav_forceId         = Force ID
   
   # buttons
   
  @@ -154,3 +156,6 @@
   js_form=Calendário como um formulário.
   js_submit=Enviar
   css_msg=Um teste simples para o
  +
  +forceOne=Value 1 @TRANSLATE
  +forceTwo=Value 2 (with forceId) @TRANSLATE
  \ No newline at end of file
  
  
  
  1.11      +4 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_ja.properties
  
  Index: example_messages_ja.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_ja.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- example_messages_ja.properties	9 Jan 2005 12:36:58 -0000	1.10
  +++ example_messages_ja.properties	10 Jan 2005 08:08:14 -0000	1.11
  @@ -31,8 +31,10 @@
   nav_panelstack      = \u30d1\u30cd\u30eb\u30b9\u30bf\u30c3\u30af
   nav_css             = \u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8
   nav_newspaperTable  = Newspaper Table
  +nav_forceId         = ForceId
   nav_swapimage       = SwapImage
   
  +
   # buttons
   
   button_save = \u4fdd\u5b58
  @@ -159,3 +161,5 @@
   css_msg=\u6b21\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u7c21\u5358\u306a\u30c6\u30b9\u30c8\u3067\u3059:
   
   
  +forceOne=Value 1 @TRANSLATE
  +forceTwo=Value 2 (with forceId) @TRANSLATE
  \ No newline at end of file
  
  
  
  1.10      +4 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_de.properties
  
  Index: example_messages_de.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages_de.properties,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- example_messages_de.properties	9 Jan 2005 12:36:58 -0000	1.9
  +++ example_messages_de.properties	10 Jan 2005 08:08:14 -0000	1.10
  @@ -30,6 +30,7 @@
   nav_Date			= Datum
   nav_css             = Stylesheet
   nav_newspaperTable  = Newspaper Table
  +nav_forceId         = ForceId
   nav_swapimage       = SwapImage
   
   # buttons
  @@ -101,3 +102,6 @@
   validate_regexp = Regular Expression
   validate_equal = Equal
   validate_isbn = ISBN
  +
  +forceOne=Eingabe 1
  +forceTwo=Eingabe 2 (mit forceId) 
  
  
  
  1.16      +5 -0      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages.properties
  
  Index: example_messages.properties
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/resource/example_messages.properties,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- example_messages.properties	9 Jan 2005 12:36:58 -0000	1.15
  +++ example_messages.properties	10 Jan 2005 08:08:14 -0000	1.16
  @@ -34,6 +34,8 @@
   nav_css             = Stylesheet
   nav_newspaperTable  = Newspaper Table
   nav_HtmlEditor		= Html Editor
  +nav_forceId         = ForceId
  +
   nav_swapimage       = SwapImage
   # buttons
   
  @@ -156,3 +158,6 @@
   js_form=Calendar as a form.
   js_submit=Submit
   css_msg=A simple test for the 
  +
  +forceOne=Value 1
  +forceTwo=Value 2 (with forceId)
  \ No newline at end of file
  
  
  
  1.42      +13 -0     incubator-myfaces/webapps/examples/web/WEB-INF/examples-config.xml
  
  Index: examples-config.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/WEB-INF/examples-config.xml,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- examples-config.xml	9 Jan 2005 12:36:58 -0000	1.41
  +++ examples-config.xml	10 Jan 2005 08:08:15 -0000	1.42
  @@ -81,6 +81,14 @@
           <managed-bean-class>org.apache.myfaces.examples.listexample.TreeTable</managed-bean-class>
           <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
  +	    
  +    <!-- Managed Beans for forceId.jsp -->
  +
  +    <managed-bean>
  +        <managed-bean-name>forceIdBean</managed-bean-name>
  +        <managed-bean-class>org.apache.myfaces.examples.misc.ForceIdBean</managed-bean-class>
  +        <managed-bean-scope>session</managed-bean-scope>
  +    </managed-bean>
   
   
       <!-- Managed Beans for simpleSortList.jsp -->
  @@ -350,6 +358,11 @@
           <navigation-case>
               <from-outcome>go_newspaperTable</from-outcome>
               <to-view-id>/newspaperTable.jsp</to-view-id>
  +        </navigation-case>
  +		
  +		        <navigation-case>
  +            <from-outcome>go_forceId</from-outcome>
  +            <to-view-id>/forceId.jsp</to-view-id>
           </navigation-case>
   
           <navigation-case>
  
  
  
  1.1                  incubator-myfaces/webapps/examples/web/forceId.jsp
  
  Index: forceId.jsp
  ===================================================================
  <%@ page import="java.math.BigDecimal,
                   java.util.Date"%>
  <%@ page session="false" contentType="text/html;charset=utf-8"%>
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
  <html>
  
  <%@include file="inc/head.inc" %>
  
  <!--
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  //-->
  
  <body>
  
  <!--
  managed beans used:
      validateForm
  -->
  
  <f:view>
  
      <f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
  
      <x:panelLayout id="page" layout="#{globalOptions.pageLayout}"
              styleClass="pageLayout"
              headerClass="pageHeader"
              navigationClass="pageNavigation"
              bodyClass="pageBody"
              footerClass="pageFooter" >
  
          <f:facet name="header">
              <f:subview id="header">
                  <jsp:include page="inc/page_header.jsp" />
              </f:subview>
          </f:facet>
  
          <f:facet name="navigation">
              <f:subview id="menu" >
                  <jsp:include page="inc/navigation.jsp" />
              </f:subview>
          </f:facet>
  
  
          <f:facet name="body">
              <h:panelGroup id="body">
  
  			<h:form id="forceIdForm" >
  			   <h:panelGrid columns="3">
  
                      <h:outputText id="forceOneOutput" value="#{example_messages['forceOne']}"/>
                      <h:inputText id="forceOne" value="#{forceIdBean.valueOne}"/>
                      <h:message id="forceOneMessage" for="forceOne" styleClass="error"
/>
  
                      <h:outputText id="forceTwoOutput" value="#{example_messages['forceTwo']}"/>
                      <x:inputText id="forceTwo" value="#{forceIdBean.valueTwo}" forceId="true"/>
                      <h:message id="forceTwoMessage" for="forceTwo" styleClass="error"
/>
  
  				<h:panelGroup/>
  			  	<h:commandButton id="button" value="#{example_messages['button_submit']}" action="go_home"/>
                      <h:panelGroup/>
  
  			    </h:panelGrid>
  			</h:form>
  
              </h:panelGroup>
          </f:facet>
  
          <%@include file="inc/page_footer.jsp" %>
  
      </x:panelLayout>
  
  </f:view>
  
  </body>
  
  </html>
  
  
  1.1                  incubator-myfaces/src/components/org/apache/myfaces/component/html/util/HtmlComponentUtils.java
  
  Index: HtmlComponentUtils.java
  ===================================================================
  /*
   * Copyright 2004 The Apache Software Foundation.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.myfaces.component.html.util;
  
  import org.apache.myfaces.renderkit.JSFAttr;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.render.Renderer;
  import java.util.HashMap;
  
  /**
   * <p>Utility class for providing basic functionality to the HTML faces 
   * extended components.<p>
   * 
   * @author not attributable
   * @version 
   */
  public class HtmlComponentUtils 
  {
      private static final String TRUE = "true";
      private static final String KEY_COMPONENT_ID_MAP = "KEY_COMPONENT_ID_MAP";
      
      /**
       * Constructor (Private)
       */
      private HtmlComponentUtils() 
      {}
      
      public static String getClientId(UIComponent component,
                                       Renderer renderer,
                                       FacesContext context)
      {
          // see if the originally supplied id should be used 
          Boolean forceValue = (Boolean)component.getAttributes().get(JSFAttr.FORCE_ID_ATTR);
          boolean forceId = forceValue.booleanValue();
          
          if (forceId && component.getId() != null)
          {
              /** @todo handle "indexed" data values */            
              String clientId = component.getId();
              
              // JSF spec requires that renderer get a chance to convert the id
              if (renderer != null)
              {
                  clientId = renderer.convertClientId(context, clientId);
              }
              
              // avoid having duplicate id's 
              HashMap idMap = (HashMap)context.getViewRoot().getAttributes().get(KEY_COMPONENT_ID_MAP);
              
              if (idMap == null)
              {
                  idMap = new HashMap();
                  context.getViewRoot().getAttributes().
                      put(KEY_COMPONENT_ID_MAP, idMap);
              }
  
              /**
               * Since components that use this utility are intended to be 
               * rendered in HTML they should conform to the XHTML standard 
               * which mandates that each component have a unique id.  
               * Right now this is pretty much impossible to enforce in the 
               * appropriate Renderer class so its being done here.
               */
              if (idMap.containsKey(clientId))
              {
                  UIComponent mappedComponent = (UIComponent)idMap.get(clientId);
                  if (component.equals(mappedComponent))
                  {
                      throw new IllegalArgumentException("Duplicate cliientId not allowed.
 View already contains the id: " + 
                          clientId);
                  }
              }
              
              return clientId;
          }
          else
          {
              return component.getClientId(context);
          }
      }
  }
  
  
  1.48      +1 -0      incubator-myfaces/webapps/examples/web/inc/navigation.jsp
  
  Index: navigation.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/inc/navigation.jsp,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- navigation.jsp	9 Jan 2005 12:36:58 -0000	1.47
  +++ navigation.jsp	10 Jan 2005 08:08:21 -0000	1.48
  @@ -34,6 +34,7 @@
               <x:commandNavigation id="nav_2_4_15" value="#{example_messages['nav_css']}"
action="go_css" />
               <x:commandNavigation id="nav_2_4_16" value="#{example_messages['nav_newspaperTable']}"
action="go_newspaperTable" />
               <x:commandNavigation id="nav_2_4_17" value="#{example_messages['nav_swapimage']}"
action="go_swapimage" />
  +            <x:commandNavigation id="nav_2_4_18" value="#{example_messages['nav_forceId']}"
action="go_forceId" />
           </x:commandNavigation>
       </x:commandNavigation>
       <x:commandNavigation id="nav_3" value="#{example_messages['nav_Documentation']}"
>
  
  
  

Mime
View raw message