CS 1705 Library

cs1705.web
Class PrintExpression

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zhtml.Text
          extended by cs1705.web.PrintExpression
All Implemented Interfaces:
Serializable, Cloneable, Component, RawId, ComponentCtrl

public class PrintExpression
extends org.zkoss.zhtml.Text

Evaluate and echo the contents of a Java expression, such as an arbitrary method call.

A <print-expression> tag has one required property and two optional properties:

Parameters
type - The (optional) Java type of the expression--this should be a legal Java class name that is in scope (see Import) (must come before the value!).
isHtml - A boolean that indicates whether the expression should be treated as a string of HTML text, or whether any special HTML entities in the value should be escaped so they show up correctly in web browsers. (Must come before the value!)
value - The expression to print. It can be any Java expression, or any EL expression (i.e., ${...}), but may not be a bound data value (no @{...}).

Examples:

 <print-expression value="myString.substring(pos, subLen)"/>

 <!-- With an included type -->
 <print-expression type="URL" value="myWebBot.getPageURL()"/>

 <!-- If you use quotes, they must be HTML-escaped -->
 <print-expression
   value="&quot;string &quot; + &quot;concatenation&quot;"/>

 <!-- A longer version, so you don't have to escape the quotes. -->
 <print-expression>
   <attribute name="value">
     "Name: " + person.getLastName() + ", " + person.getFirstName()
   </attribute>
 </variable>
 

Version:
2007.08.13
Author:
Stephen Edwards
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
PrintExpression()
          Creates a new PrintExpression component.
 
Method Summary
 boolean getIsHtml()
          Accessor for the "isHtml" property.
 String getType()
          Accessor for the "type" property, which may be null if no type has been specified.
 void setIsHtml(boolean value)
          Mutator for the "isHtml" property, which is optional.
 void setType(String newType)
          Mutator for the "type" property, which is optional.
 void setValue(Object value)
          Mutator for the "value" property, which provides the variable's initial value.
 void setValue(String value)
          Mutator for the "value" property, which provides the variable's initial value.
 
Methods inherited from class org.zkoss.zhtml.Text
getValue, invalidate, isChildable, redraw, setParent
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, clone, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getCommand, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, hasFellow, insertBefore, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onDrawNewChild, onPageAttached, onPageDetached, onWrongValue, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setPageBefore, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, smartUpdateDeferred, smartUpdateValues, toString, unsetVariable
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrintExpression

public PrintExpression()
Creates a new PrintExpression component.

Method Detail

getType

public String getType()
Accessor for the "type" property, which may be null if no type has been specified.

Returns:
The expressions's type (a Java Class name)

setType

public void setType(String newType)
Mutator for the "type" property, which is optional. Note that the expression type, if used, must be set before the value (which means the type attribute must appear to the left of the value attribute in your ZHTML code).

Parameters:
newType - The type (class) to use for the variable. The class name specified must either be fully qualified, or must have been imported (see Import).

setValue

public void setValue(Object value)
Mutator for the "value" property, which provides the variable's initial value. It must come after the name and (optional) type.

Parameters:
value - The value to use for the variable. It must be an object of the appropriate type.

setValue

public void setValue(String value)
Mutator for the "value" property, which provides the variable's initial value. It must come after the name and (optional) type.

Overrides:
setValue in class org.zkoss.zhtml.Text
Parameters:
value - A string that will be interpreted as a Java expression of the appropriate type to produce the desired variable value.

getIsHtml

public boolean getIsHtml()
Accessor for the "isHtml" property. Indicates whether or not the expression should be treated as formatted HTML text, or as plain text.

Returns:
true if the expression is interpreted as already HTML-encoded

setIsHtml

public void setIsHtml(boolean value)
Mutator for the "isHtml" property, which is optional. If used, it must be set before the value (which means the isHtml attribute must appear to the left of the value attribute in your ZHTML code).

Parameters:
value - True if this expression should be treated as HTML, or false if it should be treated as non-HTML (meaning any HTML entities should be properly escaped before the value is printed).

Last updated: Wed, Apr 1, 2009 • 12:29 AM EDT

Copyright © 2009 Virginia Tech.