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

com.icesoft.faces.component.ext.HtmlOutputLabel Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2004-2013 ICEsoft Technologies Canada Corp.
 *
 * 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 com.icesoft.faces.component.ext;

import com.icesoft.faces.component.CSS_DEFAULT;
import com.icesoft.faces.component.PORTLET_CSS_DEFAULT;
import com.icesoft.faces.component.ext.taglib.Util;
import com.icesoft.faces.context.effects.CurrentStyle;
import com.icesoft.faces.context.effects.Effect;
import com.icesoft.faces.context.effects.JavascriptContext;
import com.icesoft.faces.util.CoreUtils;

import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;


/**
 * This is an extension of javax.faces.component.html.HtmlOutputLabel, which
 * provides some additional behavior to this component such as: 
  • changes * the component's rendered state based on the authentication
  • adds * effects to the component
    • */ public class HtmlOutputLabel extends javax.faces.component.html.HtmlOutputLabel { public static final String COMPONENT_TYPE = "com.icesoft.faces.HtmlOutputLabel"; public static final String RENDERER_TYPE = "com.icesoft.faces.Label"; private static final boolean DEFAULT_VISIBLE = true; private String styleClass = null; private String renderedOnUserRole = null; private Effect effect; private Boolean visible = null; private CurrentStyle currentStyle; public HtmlOutputLabel() { super(); setRendererType(RENDERER_TYPE); } public void setValueBinding(String s, ValueBinding vb) { if (s != null && s.indexOf("effect") != -1) { // If this is an effect attribute make sure Ice Extras is included JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext()); } super.setValueBinding(s, vb); } /** *

      Set the value of the effect property.

      */ public void setEffect(Effect effect) { this.effect = effect; JavascriptContext .includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext()); } /** *

      Return the value of the effect property.

      */ public Effect getEffect() { if (effect != null) { return effect; } ValueBinding vb = getValueBinding("effect"); return vb != null ? (Effect) vb.getValue(getFacesContext()) : null; } /** *

      Set the value of the visible property.

      */ public void setVisible(boolean visible) { this.visible = Boolean.valueOf(visible); } /** *

      Return the value of the visible property.

      */ public boolean getVisible() { if (visible != null) { return visible.booleanValue(); } ValueBinding vb = getValueBinding("visible"); Boolean boolVal = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null; return boolVal != null ? boolVal.booleanValue() : DEFAULT_VISIBLE; } /** *

      Set the value of the styleClass property.

      */ public void setStyleClass(String styleClass) { this.styleClass = styleClass; } /** *

      Return the value of the styleClass property.

      */ public String getStyleClass() { return Util.getQualifiedStyleClass(this, styleClass, CSS_DEFAULT.OUTPUT_LABEL_DEFAULT_STYLE_CLASS, "styleClass", PORTLET_CSS_DEFAULT.PORTLET_FORM_LABEL); } /** *

      Set the value of the renderedOnUserRole property.

      */ public void setRenderedOnUserRole(String renderedOnUserRole) { this.renderedOnUserRole = renderedOnUserRole; } /** *

      Return the value of the renderedOnUserRole property.

      */ public String getRenderedOnUserRole() { if (renderedOnUserRole != null) { return renderedOnUserRole; } ValueBinding vb = getValueBinding("renderedOnUserRole"); return vb != null ? (String) vb.getValue(getFacesContext()) : null; } /** *

      Return the value of the rendered property.

      */ public boolean isRendered() { if (!Util.isRenderedOnUserRole(this)) { return false; } return super.isRendered(); } /** *

      Return the value of the currentStyle property.

      */ public CurrentStyle getCurrentStyle() { return currentStyle; } /** *

      Set the value of the currentStyle property.

      */ public void setCurrentStyle(CurrentStyle currentStyle) { this.currentStyle = currentStyle; } /** *

      Gets the state of the instance as a Serializable * Object.

      */ public Object saveState(FacesContext context) { Object values[] = new Object[6]; values[0] = super.saveState(context); values[1] = renderedOnUserRole; values[2] = styleClass; values[3] = effect; values[4] = currentStyle; values[5] = visible; return ((Object) (values)); } /** *

      Perform any processing required to restore the state from the entries * in the state Object.

      */ public void restoreState(FacesContext context, Object state) { Object values[] = (Object[]) state; super.restoreState(context, values[0]); renderedOnUserRole = (String) values[1]; styleClass = (String) values[2]; effect = (Effect) values[3]; currentStyle = (CurrentStyle) values[4]; visible = (Boolean) values[5]; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy