com.sun.webui.jsf.component.StaticText Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://woodstock.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://woodstock.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
*/
package com.sun.webui.jsf.component;
import javax.el.ValueExpression;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import com.sun.faces.annotation.Component;
import com.sun.faces.annotation.Property;
/**
* The StaticText component is used to display text that is not interactive in
* the rendered HTML page.
*/
@Component(type = "com.sun.webui.jsf.StaticText", family = "com.sun.webui.jsf.StaticText",
displayName = "Static Text", tagName = "staticText",
helpKey = "projrave_ui_elements_palette_wdstk-jsf1.2_static_text",
propertiesHelpKey = "projrave_ui_elements_palette_wdstk-jsf1.2_propsheets_static_text_props")
public class StaticText extends UIOutput {
/**
* Construct a new StaticText
.
*/
public StaticText() {
super();
setRendererType("com.sun.webui.jsf.StaticText");
}
/**
* Return the family for this component.
*/
@Override
public String getFamily() {
return "com.sun.webui.jsf.StaticText";
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Tag attribute methods
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
* The converter attribute is used to specify a method to translate native
* property values to String and back for this component. The converter
* attribute value must be one of the following:
*
* - A JavaServer Faces EL expression that resolves to a backing bean or
* bean property that implements the
*
javax.faces.converter.Converter
interface; or
* - the ID of a registered converter (a String).
*
*/
@Property(name = "converter")
@Override
public void setConverter(Converter converter) {
super.setConverter(converter);
}
/**
* The component identifier for this component. This value must be unique
* within the closest parent component that is a naming container.
*/
@Property(name = "id")
@Override
public void setId(String id) {
super.setId(id);
}
/**
* Use the rendered attribute to indicate whether the HTML code for the
* component should be included in the rendered HTML page. If set to false,
* the rendered HTML page does not include the HTML for the component. If
* the component is not rendered, it is also not processed on any subsequent
* form submission.
*/
@Property(name = "rendered")
@Override
public void setRendered(boolean rendered) {
super.setRendered(rendered);
}
/**
* Return the ValueExpression
stored for the
* specified name (if any), respecting any property aliases.
*
* @param name Name of value binding expression to retrieve
*/
@Override
public ValueExpression getValueExpression(String name) {
if (name.equals("text")) {
return super.getValueExpression("value");
}
return super.getValueExpression(name);
}
/**
* Set the ValueExpression
stored for the
* specified name (if any), respecting any property
* aliases.
*
* @param name Name of value binding to set
* @param binding ValueExpression to set, or null to remove
*/
@Override
public void setValueExpression(String name, ValueExpression binding) {
if (name.equals("text")) {
super.setValueExpression("value", binding);
return;
}
super.setValueExpression(name, binding);
}
// Hide Value
@Property(name = "value", isHidden = true, isAttribute = false)
@Override
public Object getValue() {
return super.getValue();
}
/**
* Escape the html text so it won't be interpreted by the browser as HTML
*/
@Property(name = "escape", displayName = "Escape", category = "Data")
private boolean escape = false;
private boolean escape_set = false;
/**
* Escape the html text so it won't be interpreted by the browser as HTML
*/
public boolean isEscape() {
if (this.escape_set) {
return this.escape;
}
ValueExpression _vb = getValueExpression("escape");
if (_vb != null) {
Object _result = _vb.getValue(getFacesContext().getELContext());
if (_result == null) {
return false;
} else {
return ((Boolean) _result).booleanValue();
}
}
return true;
}
/**
* Escape the html text so it won't be interpreted by the browser as HTML
* @see #isEscape()
*/
public void setEscape(boolean escape) {
this.escape = escape;
this.escape_set = true;
}
/**
* Scripting code executed when a mouse click
* occurs over this component.
*/
@Property(name = "onClick", displayName = "Click Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onClick = null;
/**
* Scripting code executed when a mouse click
* occurs over this component.
*/
public String getOnClick() {
if (this.onClick != null) {
return this.onClick;
}
ValueExpression _vb = getValueExpression("onClick");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when a mouse click
* occurs over this component.
* @see #getOnClick()
*/
public void setOnClick(String onClick) {
this.onClick = onClick;
}
/**
* Scripting code executed when a mouse double click
* occurs over this component.
*/
@Property(name = "onDblClick", displayName = "Double Click Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onDblClick = null;
/**
* Scripting code executed when a mouse double click
* occurs over this component.
*/
public String getOnDblClick() {
if (this.onDblClick != null) {
return this.onDblClick;
}
ValueExpression _vb = getValueExpression("onDblClick");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when a mouse double click
* occurs over this component.
* @see #getOnDblClick()
*/
public void setOnDblClick(String onDblClick) {
this.onDblClick = onDblClick;
}
/**
* Scripting code executed when the user presses a mouse button while the
* mouse pointer is on the component.
*/
@Property(name = "onMouseDown", displayName = "Mouse Down Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onMouseDown = null;
/**
* Scripting code executed when the user presses a mouse button while the
* mouse pointer is on the component.
*/
public String getOnMouseDown() {
if (this.onMouseDown != null) {
return this.onMouseDown;
}
ValueExpression _vb = getValueExpression("onMouseDown");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when the user presses a mouse button while the
* mouse pointer is on the component.
* @see #getOnMouseDown()
*/
public void setOnMouseDown(String onMouseDown) {
this.onMouseDown = onMouseDown;
}
/**
* Scripting code executed when the user moves the mouse pointer while
* over the component.
*/
@Property(name = "onMouseMove", displayName = "Mouse Move Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onMouseMove = null;
/**
* Scripting code executed when the user moves the mouse pointer while
* over the component.
*/
public String getOnMouseMove() {
if (this.onMouseMove != null) {
return this.onMouseMove;
}
ValueExpression _vb = getValueExpression("onMouseMove");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when the user moves the mouse pointer while
* over the component.
* @see #getOnMouseMove()
*/
public void setOnMouseMove(String onMouseMove) {
this.onMouseMove = onMouseMove;
}
/**
* Scripting code executed when a mouse out movement
* occurs over this component.
*/
@Property(name = "onMouseOut", displayName = "Mouse Out Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onMouseOut = null;
/**
* Scripting code executed when a mouse out movement
* occurs over this component.
*/
public String getOnMouseOut() {
if (this.onMouseOut != null) {
return this.onMouseOut;
}
ValueExpression _vb = getValueExpression("onMouseOut");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when a mouse out movement
* occurs over this component.
* @see #getOnMouseOut()
*/
public void setOnMouseOut(String onMouseOut) {
this.onMouseOut = onMouseOut;
}
/**
* Scripting code executed when the user moves the mouse pointer into
* the boundary of this component.
*/
@Property(name = "onMouseOver", displayName = "Mouse In Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onMouseOver = null;
/**
* Scripting code executed when the user moves the mouse pointer into
* the boundary of this component.
*/
public String getOnMouseOver() {
if (this.onMouseOver != null) {
return this.onMouseOver;
}
ValueExpression _vb = getValueExpression("onMouseOver");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when the user moves the mouse pointer into
* the boundary of this component.
* @see #getOnMouseOver()
*/
public void setOnMouseOver(String onMouseOver) {
this.onMouseOver = onMouseOver;
}
/**
* Scripting code executed when the user releases a mouse button while
* the mouse pointer is on the component.
*/
@Property(name = "onMouseUp", displayName = "Mouse Up Script", category = "Javascript",
editorClassName = "com.sun.rave.propertyeditors.JavaScriptPropertyEditor")
private String onMouseUp = null;
/**
* Scripting code executed when the user releases a mouse button while
* the mouse pointer is on the component.
*/
public String getOnMouseUp() {
if (this.onMouseUp != null) {
return this.onMouseUp;
}
ValueExpression _vb = getValueExpression("onMouseUp");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Scripting code executed when the user releases a mouse button while
* the mouse pointer is on the component.
* @see #getOnMouseUp()
*/
public void setOnMouseUp(String onMouseUp) {
this.onMouseUp = onMouseUp;
}
/**
* CSS style(s) to be applied to the outermost HTML element when this
* component is rendered.
*/
@Property(name = "style", displayName = "CSS Style(s)", category = "Appearance",
editorClassName = "com.sun.jsfcl.std.css.CssStylePropertyEditor")
private String style = null;
/**
* CSS style(s) to be applied to the outermost HTML element when this
* component is rendered.
*/
public String getStyle() {
if (this.style != null) {
return this.style;
}
ValueExpression _vb = getValueExpression("style");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* CSS style(s) to be applied to the outermost HTML element when this
* component is rendered.
* @see #getStyle()
*/
public void setStyle(String style) {
this.style = style;
}
/**
* CSS style class(es) to be applied to the outermost HTML element when this
* component is rendered.
*/
@Property(name = "styleClass", displayName = "CSS Style Class(es)", category = "Appearance",
editorClassName = "com.sun.rave.propertyeditors.StyleClassPropertyEditor")
private String styleClass = null;
/**
* CSS style class(es) to be applied to the outermost HTML element when this
* component is rendered.
*/
public String getStyleClass() {
if (this.styleClass != null) {
return this.styleClass;
}
ValueExpression _vb = getValueExpression("styleClass");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* CSS style class(es) to be applied to the outermost HTML element when this
* component is rendered.
* @see #getStyleClass()
*/
public void setStyleClass(String styleClass) {
this.styleClass = styleClass;
}
/**
* The text to be displayed for this component.
*/
@Property(name = "text", displayName = "Text", category = "Appearance", isDefault = true,
editorClassName = "com.sun.rave.propertyeditors.StringPropertyEditor")
public Object getText() {
return getValue();
}
/**
* The text to be displayed for this component.
* @see #getText()
*/
public void setText(Object text) {
setValue(text);
}
/**
* Sets the value of the title attribute for the HTML element.
* The specified text will display as a tooltip if the mouse cursor hovers
* over the HTML element.
*/
@Property(name = "toolTip", displayName = "Tool Tip", category = "Behavior",
editorClassName = "com.sun.rave.propertyeditors.StringPropertyEditor")
private String toolTip = null;
/**
* Sets the value of the title attribute for the HTML element.
* The specified text will display as a tooltip if the mouse cursor hovers
* over the HTML element.
*/
public String getToolTip() {
if (this.toolTip != null) {
return this.toolTip;
}
ValueExpression _vb = getValueExpression("toolTip");
if (_vb != null) {
return (String) _vb.getValue(getFacesContext().getELContext());
}
return null;
}
/**
* Sets the value of the title attribute for the HTML element.
* The specified text will display as a tooltip if the mouse cursor hovers
* over the HTML element.
* @see #getToolTip()
*/
public void setToolTip(String toolTip) {
this.toolTip = toolTip;
}
/**
* Use the visible attribute to indicate whether the component should be
* viewable by the user in the rendered HTML page. If set to false, the
* HTML code for the component is present in the page, but the component
* is hidden with style attributes. By default, visible is set to true, so
* HTML for the component HTML is included and visible to the user. If the
* component is not visible, it can still be processed on subsequent form
* submissions because the HTML is present.
*/
@Property(name = "visible", displayName = "Visible", category = "Behavior")
private boolean visible = false;
private boolean visible_set = false;
/**
* Use the visible attribute to indicate whether the component should be
* viewable by the user in the rendered HTML page. If set to false, the
* HTML code for the component is present in the page, but the component
* is hidden with style attributes. By default, visible is set to true, so
* HTML for the component HTML is included and visible to the user. If the
* component is not visible, it can still be processed on subsequent form
* submissions because the HTML is present.
*/
public boolean isVisible() {
if (this.visible_set) {
return this.visible;
}
ValueExpression _vb = getValueExpression("visible");
if (_vb != null) {
Object _result = _vb.getValue(getFacesContext().getELContext());
if (_result == null) {
return false;
} else {
return ((Boolean) _result).booleanValue();
}
}
return true;
}
/**
* Use the visible attribute to indicate whether the component should be
* viewable by the user in the rendered HTML page. If set to false, the
* HTML code for the component is present in the page, but the component
* is hidden with style attributes. By default, visible is set to true, so
* HTML for the component HTML is included and visible to the user. If the
* component is not visible, it can still be processed on subsequent form
* submissions because the HTML is present.
* @see #isVisible()
*/
public void setVisible(boolean visible) {
this.visible = visible;
this.visible_set = true;
}
/**
* Restore the state of this component.
*/
@Override
public void restoreState(FacesContext _context, Object _state) {
Object _values[] = (Object[]) _state;
super.restoreState(_context, _values[0]);
this.escape = ((Boolean) _values[1]).booleanValue();
this.escape_set = ((Boolean) _values[2]).booleanValue();
this.onClick = (String) _values[3];
this.onDblClick = (String) _values[4];
this.onMouseDown = (String) _values[5];
this.onMouseMove = (String) _values[6];
this.onMouseOut = (String) _values[7];
this.onMouseOver = (String) _values[8];
this.onMouseUp = (String) _values[9];
this.style = (String) _values[10];
this.styleClass = (String) _values[11];
this.toolTip = (String) _values[12];
this.visible = ((Boolean) _values[13]).booleanValue();
this.visible_set = ((Boolean) _values[14]).booleanValue();
}
/**
* Save the state of this component.
*/
@Override
public Object saveState(FacesContext _context) {
Object _values[] = new Object[15];
_values[0] = super.saveState(_context);
_values[1] = this.escape ? Boolean.TRUE : Boolean.FALSE;
_values[2] = this.escape_set ? Boolean.TRUE : Boolean.FALSE;
_values[3] = this.onClick;
_values[4] = this.onDblClick;
_values[5] = this.onMouseDown;
_values[6] = this.onMouseMove;
_values[7] = this.onMouseOut;
_values[8] = this.onMouseOver;
_values[9] = this.onMouseUp;
_values[10] = this.style;
_values[11] = this.styleClass;
_values[12] = this.toolTip;
_values[13] = this.visible ? Boolean.TRUE : Boolean.FALSE;
_values[14] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
return _values;
}
}