All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.struts.faces.component.WriteComponent Maven / Gradle / Ivy

There is a newer version: 1.5.0-RC2
Show newest version
/*
 * $Id$
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.struts.faces.component;


import javax.el.ValueExpression;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;


/**
 * 

Custom component that replaces the Struts * <html:write> tag.

*/ public class WriteComponent extends UIOutput { // ------------------------------------------------------------ Constructors /** *

Create a new {@link WriteComponent} with default properties.

*/ public WriteComponent() { super(); setRendererType("org.apache.struts.faces.Write"); } // ------------------------------------------------------ Instance Variables /** *

Flag indicating whether output should be filtered.

*/ private boolean filter = true; private boolean filterSet = false; /** *

CSS style(s) to be rendered for this component.

*/ private String style = null; /** *

CSS style class(es) to be rendered for this component.

*/ private String styleClass = null; // ---------------------------------------------------- Component Properties /** *

Return the component family to which this component belongs.

*/ public String getFamily() { return "org.apache.struts.faces.Write"; } /** *

Return a flag indicating whether filtering should take place.

*/ public boolean isFilter() { if (filterSet) { return filter; } ValueExpression vb = getValueExpression("filter"); if (vb != null) { Boolean value = (Boolean) vb.getValue(getFacesContext().getELContext()); if (null == value) { return filter; } return value.booleanValue(); } else { return filter; } } /** *

Set the flag indicating that the output value should be filtered.

* * @param filter The new filter flag */ public void setFilter(boolean filter) { this.filter = filter; this.filterSet = true; } /** *

Return the CSS style(s) to be rendered for this component.

*/ public String getStyle() { ValueExpression vb = getValueExpression("style"); if (vb != null) { return (String) vb.getValue(getFacesContext().getELContext()); } else { return style; } } /** *

Set the CSS style(s) to be rendered for this component.

* * @param style The new CSS style(s) */ public void setStyle(String style) { this.style = style; } /** *

Return the CSS style class(es) to be rendered for this component.

*/ public String getStyleClass() { ValueExpression vb = getValueExpression("styleClass"); if (vb != null) { return (String) vb.getValue(getFacesContext().getELContext()); } else { return styleClass; } } /** *

Set the CSS style class(es) to be rendered for this component.

* * @param styleClass The new CSS style class(es) */ public void setStyleClass(String styleClass) { this.styleClass = styleClass; } // ---------------------------------------------------- StateManager Methods /** *

Restore the state of this component.

* * @param context FacesContext for the current request * @param state State object from which to restore our state */ public void restoreState(FacesContext context, Object state) { Object values[] = (Object[]) state; super.restoreState(context, values[0]); filter = ((Boolean) values[1]).booleanValue(); filterSet = ((Boolean) values[2]).booleanValue(); style = (String) values[3]; styleClass = (String) values[4]; } /** *

Save the state of this component.

* * @param context FacesContext for the current request */ public Object saveState(FacesContext context) { Object values[] = new Object[5]; values[0] = super.saveState(context); values[1] = filter ? Boolean.TRUE : Boolean.FALSE; values[2] = filterSet ? Boolean.TRUE : Boolean.FALSE; values[3] = style; values[4] = styleClass; return values; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy