org.odlabs.wiquery.core.options
Class Options

java.lang.Object
  extended by org.odlabs.wiquery.core.options.Options
All Implemented Interfaces:
Serializable, org.apache.wicket.IClusterable, org.apache.wicket.model.IDetachable, org.apache.wicket.model.IModel<Options>
Direct Known Subclasses:
DatePickerOptions

public class Options
extends Object
implements org.apache.wicket.model.IModel<Options>

$Id$

Wraps a set of options possibly defined for a WiQuery Component.

By default, Options are rendered as a JavaScript object like this:

  {
        option1: 'value1',
        option2: 'value2
  }
 
This rendering can be customized by creating a IOptionsRenderer.

Since:
0.5
Author:
Lionel Armanet, Hielke Hoeve, Ernesto Reinaldo Barreiro
See Also:
Serialized Form

Constructor Summary
Options()
          Build a new empty Options instance that does not bind to a component.
Options(org.apache.wicket.Component owner)
          Build a new empty Options instance that binds to a component
 
Method Summary
 boolean containsKey(Object key)
           Returns if the given option is defined or not.
 void detach()
           
 String get(String key)
           Returns the given option value as a String.
 Boolean getBoolean(String key)
           Returns the given option value.
 IComplexOption getComplexOption(String key)
           Returns the given option value.
 Double getDouble(String key)
           Returns the given option value.
 Float getFloat(String key)
           Returns the given option value.
 Integer getInt(String key)
           Returns the given option value.
 CharSequence getJavaScriptOptions()
          Returns the JavaScript statement corresponding to options.
 JsScope getJsScope(String key)
           Returns the given option value.
 ICollectionItemOptions getListItemOptions(String key)
           Returns the given option value.
 String getLiteral(String key)
           Returns the given option value.
 Options getObject()
           
 Short getShort(String key)
           Returns the given option value.
 boolean isEmpty()
           
 Options put(String key, boolean value)
           Put an boolean value for the given option name.
 Options put(String key, double value)
           Puts an double value for the given option name.
 Options put(String key, float value)
           Puts an float value for the given option name.
 Options put(String key, ICollectionItemOptions value)
           Puts a list of IListItemOption value for the given option name.
 Options put(String key, IComplexOption value)
           Puts a complex option value for the given option name.
 Options put(String key, int value)
           Puts an int value for the given option name.
 Options put(String key, JsScope value)
           Puts a JsScope value for the given option name.
 Options put(String key, long value)
           Puts a Long value for the given option name.
 Options put(String key, short value)
           Puts an short value for the given option name.
 Options put(String key, String value)
           Puts a String value for the given option name.
 Options putBoolean(String key, org.apache.wicket.model.IModel<Boolean> value)
           Put an boolean value for the given option name.
 Options putDouble(String key, org.apache.wicket.model.IModel<Double> value)
           Puts an IModel <Double> value for the given option name.
 Options putFloat(String key, org.apache.wicket.model.IModel<Float> value)
           Puts an IModel <Double> value for the given option name.
 Options putInteger(String key, org.apache.wicket.model.IModel<Integer> value)
           Puts an int value for the given option name.
 Options putLiteral(String key, org.apache.wicket.model.IModel<String> value)
           Puts a String value as a JavaScript literal for the given name.
 Options putLiteral(String key, String value)
           Puts a String value as a JavaScript literal for the given name.
 Options putLong(String key, org.apache.wicket.model.IModel<Long> value)
           Puts a Long value for the given option name.
 Options putShort(String key, org.apache.wicket.model.IModel<Short> value)
           Puts an short value for the given option name.
 Options putString(String key, org.apache.wicket.model.IModel<String> value)
           Puts a String value for the given option name.
 void removeOption(String key)
           Removes an option for a given name.
 void setObject(Options object)
           
 void setOwner(org.apache.wicket.Component owner)
           
 void setRenderer(IOptionsRenderer optionsRenderer)
          Sets the renderer to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Options

public Options()
Build a new empty Options instance that does not bind to a component. This does not allow the usage of IComponentAssignedModels as option values.


Options

public Options(org.apache.wicket.Component owner)
Build a new empty Options instance that binds to a component

Method Detail

setOwner

public void setOwner(org.apache.wicket.Component owner)

containsKey

public boolean containsKey(Object key)

Returns if the given option is defined or not.

Parameters:
key - the option name.

get

public String get(String key)

Returns the given option value as a String.

Parameters:
key - the option name.

getBoolean

public Boolean getBoolean(String key)

Returns the given option value.

Parameters:
key - the option name.

getJsScope

public JsScope getJsScope(String key)

Returns the given option value.

Parameters:
key - the option name.

getComplexOption

public IComplexOption getComplexOption(String key)

Returns the given option value.

Parameters:
key - the option name.
Returns:
the complex option

getDouble

public Double getDouble(String key)

Returns the given option value.

Parameters:
key - the option name.

getFloat

public Float getFloat(String key)

Returns the given option value.

Parameters:
key - the option name.

getInt

public Integer getInt(String key)

Returns the given option value.

Parameters:
key - the option name.

getJavaScriptOptions

public CharSequence getJavaScriptOptions()
Returns the JavaScript statement corresponding to options.


getListItemOptions

public ICollectionItemOptions getListItemOptions(String key)

Returns the given option value.

Parameters:
key - the option name.
Returns:
the list

getLiteral

public String getLiteral(String key)

Returns the given option value.

Parameters:
key - the option name.

getShort

public Short getShort(String key)

Returns the given option value.

Parameters:
key - the option name.

isEmpty

public boolean isEmpty()
Returns:
true if no options are defined, false otherwise.

put

public Options put(String key,
                   boolean value)

Put an boolean value for the given option name.

Parameters:
key - the option name.
value - the boolean value.

putBoolean

public Options putBoolean(String key,
                          org.apache.wicket.model.IModel<Boolean> value)

Put an boolean value for the given option name.

Parameters:
key - the option name.
value - the boolean value.

put

public Options put(String key,
                   double value)

Puts an double value for the given option name.

Parameters:
key - the option name.
value - the float double.

putDouble

public Options putDouble(String key,
                         org.apache.wicket.model.IModel<Double> value)

Puts an IModel <Double> value for the given option name.

Parameters:
key - the option name.
value - the float value.

put

public Options put(String key,
                   float value)

Puts an float value for the given option name.

Parameters:
key - the option name
value - The float value
Returns:

putFloat

public Options putFloat(String key,
                        org.apache.wicket.model.IModel<Float> value)

Puts an IModel <Double> value for the given option name.

Parameters:
key - the option name.
value - the float double.

put

public Options put(String key,
                   ICollectionItemOptions value)

Puts a list of IListItemOption value for the given option name.

Parameters:
key - the option name.
value - the IListItemOption list.

put

public Options put(String key,
                   IComplexOption value)

Puts a complex option value for the given option name.

Parameters:
key - the option name.
value - the IComplexOption.

put

public Options put(String key,
                   int value)

Puts an int value for the given option name.

Parameters:
key - the option name.
value - the int value.

putInteger

public Options putInteger(String key,
                          org.apache.wicket.model.IModel<Integer> value)

Puts an int value for the given option name.

Parameters:
key - the option name.
value - the int value.

put

public Options put(String key,
                   JsScope value)

Puts a JsScope value for the given option name.

Parameters:
key - the option name.
value - the JsScope value.

put

public Options put(String key,
                   short value)

Puts an short value for the given option name.

Parameters:
key - the option name.
value - the short value.

putShort

public Options putShort(String key,
                        org.apache.wicket.model.IModel<Short> value)

Puts an short value for the given option name.

Parameters:
key - the option name.
value - the short value.

put

public Options put(String key,
                   String value)

Puts a String value for the given option name.

Parameters:
key - the option name.
value - the String value.

putString

public Options putString(String key,
                         org.apache.wicket.model.IModel<String> value)

Puts a String value for the given option name.

Parameters:
key - the option name.
value - the String value.

put

public Options put(String key,
                   long value)

Puts a Long value for the given option name.

Parameters:
key - the option name.
value - the Long value.

putLong

public Options putLong(String key,
                       org.apache.wicket.model.IModel<Long> value)

Puts a Long value for the given option name.

Parameters:
key - the option name.
value - the Long value.

putLiteral

public Options putLiteral(String key,
                          String value)

Puts a String value as a JavaScript literal for the given name.

Note that the JavaScript resulting from this options will be 'value'

Parameters:
key - the option name.
value - the LiteralOption value.

putLiteral

public Options putLiteral(String key,
                          org.apache.wicket.model.IModel<String> value)

Puts a String value as a JavaScript literal for the given name.

Note that the JavaScript resulting from this options will be 'value'

Parameters:
key - the option name.
value - the LiteralOption value.

removeOption

public void removeOption(String key)

Removes an option for a given name.

Parameters:
key - the option's key to remove.

setRenderer

public void setRenderer(IOptionsRenderer optionsRenderer)
Sets the renderer to use.


getObject

public Options getObject()
Specified by:
getObject in interface org.apache.wicket.model.IModel<Options>

setObject

public void setObject(Options object)
Specified by:
setObject in interface org.apache.wicket.model.IModel<Options>

detach

public void detach()
Specified by:
detach in interface org.apache.wicket.model.IDetachable


Copyright © 2012. All Rights Reserved.