com.ibm.xsp.resource
Class ScriptResource

java.lang.Object
  extended by com.ibm.xsp.complex.ValueBindingObjectImpl
      extended by com.ibm.xsp.resource.AbstractResource
          extended by com.ibm.xsp.resource.ScriptResource
All Implemented Interfaces:
ComponentBindingObject, EncodableObject, ValueBindingObject, FacesAttrsObject, Resource, javax.faces.component.StateHolder

public class ScriptResource
extends AbstractResource
implements EncodableObject, FacesAttrsObject

Corresponds to the xp:script tag which defines a client or server-side script library


Field Summary
static java.lang.String RENDERER_TYPE
           
static java.lang.String TYPE_DEFAULT
          The type to use if getType() returns null: "text/javascript"
 
Fields inherited from class com.ibm.xsp.resource.AbstractResource
FAMILY
 
Constructor Summary
ScriptResource()
          Default Constructor
ScriptResource(java.lang.String src, boolean clientSide)
          Constructor
 
Method Summary
 void addAttr(Attr attr)
          Add an Attr, to appear as an attribute in the HTML output of this control or object tag.
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
          An unmodifiable map of attributes to output on the HTML script tag.
 java.util.List<Attr> getAttrs()
          The extra attributes to be output on the base element at the root of this control or object tag.
 java.lang.String getCharset()
          Returns the character encoding of the script designated by the link
 java.lang.String getContents()
          For script resources, the "contents" property can be set in the XPage source and this method can be used to retrieve the XPage source value.
 java.lang.String getServerResourceContents()
           
 java.lang.String getSrc()
          Returns the location of an external script
 java.lang.String getType()
          Returns the type of script language being used
 boolean isClientSide()
          Returns true if script is client side only, false if not
 java.lang.String removeAttribute(java.lang.String name)
          Add an attribute
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 java.lang.String setAttribute(java.lang.String name, java.lang.String value)
          Add an attribute
 void setAttrs(java.util.List<Attr> attrs)
          This method is not used by the XPage generated .java file - instead the addAttr(Attr) method is used to add attributes to the list.
 void setCharset(java.lang.String charset)
          Sets the character encoding
 void setClientSide(boolean clientSide)
          Set the clientSide value
 void setContents(java.lang.String contents)
          Set the contents of the script
 void setSrc(java.lang.String src)
          The src location of the external script
 void setType(java.lang.String type)
          The type of script language to be set.
 java.lang.String toString()
           
 
Methods inherited from class com.ibm.xsp.resource.AbstractResource
encodeObject, equals, getFamily, getRendererType, getServerResourceContents, getUniqueId, isRendered, loadContents, setRendered, setRendererType
 
Methods inherited from class com.ibm.xsp.complex.ValueBindingObjectImpl
getComponent, getFacesContext, getValueBinding, isTransient, setComponent, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.xsp.complex.EncodableObject
encodeObject
 

Field Detail

TYPE_DEFAULT

public static final java.lang.String TYPE_DEFAULT
The type to use if getType() returns null: "text/javascript"

See Also:
Constant Field Values

RENDERER_TYPE

public static final java.lang.String RENDERER_TYPE
See Also:
Constant Field Values
Constructor Detail

ScriptResource

public ScriptResource()
Default Constructor


ScriptResource

public ScriptResource(java.lang.String src,
                      boolean clientSide)
Constructor

Method Detail

isClientSide

public boolean isClientSide()
Returns true if script is client side only, false if not

Returns:
clientSide

setClientSide

public void setClientSide(boolean clientSide)
Set the clientSide value

Parameters:
clientSide -

setAttribute

public java.lang.String setAttribute(java.lang.String name,
                                     java.lang.String value)
Add an attribute

Parameters:
name - the attribute to add to the list
value - the attribute to add to the list

removeAttribute

public java.lang.String removeAttribute(java.lang.String name)
Add an attribute

Parameters:
name - the attribute to add to the list
value - the attribute to add to the list

getAttributes

public java.util.Map<java.lang.String,java.lang.String> getAttributes()
An unmodifiable map of attributes to output on the HTML script tag. Note, this property is not represented in the All Properties view, it is only used for programmatic interaction with clientSide ScriptResources. The getAttrs() property may be set in the XPage source.

Returns:
map of attributes

getType

public java.lang.String getType()
Returns the type of script language being used

Returns:

setType

public void setType(java.lang.String type)
The type of script language to be set.

Parameters:
type -

getSrc

public java.lang.String getSrc()
Returns the location of an external script

Returns:
Returns the src

setSrc

public void setSrc(java.lang.String src)
The src location of the external script

Parameters:
src -

getCharset

public java.lang.String getCharset()
Returns the character encoding of the script designated by the link

Returns:
Returns the charset

setCharset

public void setCharset(java.lang.String charset)
Sets the character encoding

Parameters:
charset -

getContents

public java.lang.String getContents()
For script resources, the "contents" property can be set in the XPage source and this method can be used to retrieve the XPage source value.

Returns:
contents of script

setContents

public void setContents(java.lang.String contents)
Set the contents of the script

Parameters:
contents - The contents to set.

getAttrs

public java.util.List<Attr> getAttrs()
The extra attributes to be output on the base element at the root of this control or object tag. This should only be used when none of the properties in the All Properties pane correspond to the desired attribute. This may return null. The addAttr(Attr) method should be used to add an Attr.

Specified by:
getAttrs in interface FacesAttrsObject

addAttr

public void addAttr(Attr attr)
Add an Attr, to appear as an attribute in the HTML output of this control or object tag. This is only used when isClientSide() is true.

Specified by:
addAttr in interface FacesAttrsObject
Parameters:
action -

setAttrs

public void setAttrs(java.util.List<Attr> attrs)
This method is not used by the XPage generated .java file - instead the addAttr(Attr) method is used to add attributes to the list.


getServerResourceContents

public java.lang.String getServerResourceContents()
                                           throws java.io.IOException
Returns:
contents from script located on server
Throws:
java.io.IOException

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class AbstractResource

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class AbstractResource

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object