myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svieu...@apache.org
Subject cvs commit: incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/aliasexample AliasHolder.java
Date Tue, 23 Nov 2004 04:46:40 GMT
svieujot    2004/11/22 20:46:40

  Modified:    tlds     myfaces_ext.tld
               src/components/org/apache/myfaces/custom/aliasbean
                        AliasBeanTag.java AliasBean.java
               webapps/examples/web aliasBean.jsp
               webapps/examples/src/org/apache/myfaces/examples/aliasexample
                        AliasHolder.java
  Log:
  Add an ugly "permanent" tag to x:aliasBean to handle children events.
  
  Revision  Changes    Path
  1.126     +5 -0      incubator-myfaces/tlds/myfaces_ext.tld
  
  Index: myfaces_ext.tld
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/tlds/myfaces_ext.tld,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- myfaces_ext.tld	20 Nov 2004 20:17:05 -0000	1.125
  +++ myfaces_ext.tld	23 Nov 2004 04:46:39 -0000	1.126
  @@ -1437,6 +1437,11 @@
               <required>true</required>
               <rtexprvalue>false</rtexprvalue>
           </attribute>
  +        <attribute>
  +            <name>permanent</name>
  +            <required>false</required>
  +            <rtexprvalue>false</rtexprvalue>
  +        </attribute>
       </tag>
   
       <!-- saveState -->
  
  
  
  1.2       +10 -1     incubator-myfaces/src/components/org/apache/myfaces/custom/aliasbean/AliasBeanTag.java
  
  Index: AliasBeanTag.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/aliasbean/AliasBeanTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AliasBeanTag.java	8 Nov 2004 20:43:15 -0000	1.1
  +++ AliasBeanTag.java	23 Nov 2004 04:46:40 -0000	1.2
  @@ -23,6 +23,9 @@
    * @author Sylvain Vieujot (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.2  2004/11/23 04:46:40  svieujot
  + * Add an ugly "permanent" tag to x:aliasBean to handle children events.
  + *
    * Revision 1.1  2004/11/08 20:43:15  svieujot
    * Add an x:aliasBean component
    *
  @@ -31,12 +34,14 @@
       
       private String _sourceBean;
       private String _alias;
  +    private String _permanent;
       
       protected void setProperties(UIComponent component) {
           super.setProperties(component);
   
           setStringProperty(component, "sourceBean", _sourceBean);
           setStringProperty(component, "alias", _alias);
  +        setBooleanProperty(component, "permanent", _permanent);
       }
       
       public String getComponentType() {
  @@ -53,5 +58,9 @@
       
       public void setAlias(String alias){
           _alias = alias;
  +    }
  +    
  +    public void setPermanent(String permanent){
  +        _permanent = permanent;
       }
   }
  
  
  
  1.3       +25 -11    incubator-myfaces/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java
  
  Index: AliasBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AliasBean.java	14 Nov 2004 15:06:36 -0000	1.2
  +++ AliasBean.java	23 Nov 2004 04:46:40 -0000	1.3
  @@ -41,6 +41,9 @@
    * @author Sylvain Vieujot (latest modification by $Author$)
    * @version $Revision$ $Date$
    * $Log$
  + * Revision 1.3  2004/11/23 04:46:40  svieujot
  + * Add an ugly "permanent" tag to x:aliasBean to handle children events.
  + *
    * Revision 1.2  2004/11/14 15:06:36  svieujot
    * Improve AliasBean to make the alias effective only within the tag body
    *
  @@ -58,6 +61,8 @@
       private String _sourceBeanExpression = null;
   
       private String _aliasBeanExpression = null;
  +    
  +    private Boolean _permanent = null;
   
       public AliasBean() {
           setRendererType(DEFAULT_RENDERER_TYPE);
  @@ -69,12 +74,22 @@
   
       public Object saveState(FacesContext context) {
           log.debug("saveState");
  -        Object values[] = new Object[3];
  +        Object values[] = new Object[4];
           values[0] = super.saveState(context);
           values[1] = _sourceBeanExpression;
           values[2] = _aliasBeanExpression;
  +        values[3] = _permanent; 
           return values;
       }
  +    
  +    public void restoreState(FacesContext context, Object state) {
  +        log.debug("restoreState");
  +        Object values[] = (Object[]) state;
  +        super.restoreState(context, values[0]);
  +        _sourceBeanExpression = (String) values[1];
  +        _aliasBeanExpression = (String) values[2];
  +        _permanent = (Boolean) values[3];
  +    }
   
       public Object processSaveState(FacesContext context) {
           // This is the same code as the one from UIComponentBase
  @@ -145,14 +160,6 @@
           removeAlias(context);
       }
   
  -    public void restoreState(FacesContext context, Object state) {
  -        log.debug("restoreState");
  -        Object values[] = (Object[]) state;
  -        super.restoreState(context, values[0]);
  -        _sourceBeanExpression = (String) values[1];
  -        _aliasBeanExpression = (String) values[2];
  -    }
  -
       public void processValidators(FacesContext context) {
           log.debug("processValidators");
           makeAlias(context);
  @@ -166,7 +173,7 @@
           super.processUpdates(context);
           removeAlias(context);
       }
  -
  +    
       void makeAlias(FacesContext context) {
           ValueBinding sourceBeanVB;
           if (_sourceBeanExpression == null) {
  @@ -192,6 +199,13 @@
       }
   
       void removeAlias(FacesContext context) {
  +        if( _permanent == null ){
  +            _permanent = (Boolean) getAttributes().get("permanent");
  +        }
  +        
  +        if( _permanent != null && _permanent.booleanValue() ) // permanent == true.
Don't remove the alias.
  +            return;
  +
           log.debug("removeAlias: " + _sourceBeanExpression + " != " + _aliasBeanExpression);
   
           ValueBinding aliasVB = getValueBinding("alias");
  
  
  
  1.3       +10 -7     incubator-myfaces/webapps/examples/web/aliasBean.jsp
  
  Index: aliasBean.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/aliasBean.jsp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- aliasBean.jsp	14 Nov 2004 15:06:36 -0000	1.2
  +++ aliasBean.jsp	23 Nov 2004 04:46:40 -0000	1.3
  @@ -69,20 +69,23 @@
   					<f:verbatim><h2>aliasTest1</h2></f:verbatim>
   					<x:aliasBean sourceBean="#{aliasTest1}" alias="#{holder}">
   						<f:subview id="simulatedIncludedSubform1">
  -								<%-- The next tags could be inserted by an %@ include or jsp:include --%>
  -								<h:outputLabel for="name" value="Name :"/>
  -	    	                    <h:inputText id="name" value="#{holder.name}"/>
  +							<%-- The next tags could be inserted by an %@ include or jsp:include --%>
  +							<h:outputLabel for="name" value="Name :"/>
  +	    	                <h:inputText id="name" value="#{holder.name}"/>
   						</f:subview>
   					</x:aliasBean>
   
   					<f:verbatim><h2>aliasTest2</h2></f:verbatim>
  -					<x:aliasBean sourceBean="#{aliasTest2}" alias="#{holder}">
  +					<x:aliasBean sourceBean="#{aliasTest2}" alias="#{holder}" permanent="true">
   						<f:subview id="simulatedIncludedSubform2">
  -								<%-- The next tags could be inserted by an %@ include or jsp:include --%>
  -								<h:outputLabel for="name" value="Name :"/>
  -	    	                    <h:inputText id="name" value="#{holder.name}"/>
  +							<%-- The next tags could be inserted by an %@ include or jsp:include --%>
  +							<h:outputLabel for="name" value="Name :"/>
  +	    	                <h:inputText id="name" value="#{holder.name}"/>
  +							<h:commandButton value="toUpperCase" action="#{holder.toUpperCase}"/>
   						</f:subview>
   					</x:aliasBean>
  +
  +					<f:verbatim><br/><br/></f:verbatim>
   
   					<h:commandButton/>
   				</h:form>
  
  
  
  1.2       +7 -1      incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/aliasexample/AliasHolder.java
  
  Index: AliasHolder.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/examples/src/org/apache/myfaces/examples/aliasexample/AliasHolder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AliasHolder.java	14 Nov 2004 15:06:36 -0000	1.1
  +++ AliasHolder.java	23 Nov 2004 04:46:40 -0000	1.2
  @@ -35,4 +35,10 @@
           log.debug("set name="+name);
           this.name = name;
       }
  +    
  +    public String toUpperCase(){
  +        name = name.toUpperCase();
  +        log.debug("toUpperCase command executed");
  +        return null;
  +    }
   }
  
  
  

Mime
View raw message