|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.smartgwt.client.core.JsObject
com.smartgwt.client.core.DataClass
com.smartgwt.client.core.RefDataClass
com.smartgwt.client.widgets.form.fields.FormItem
com.smartgwt.client.widgets.form.fields.CanvasItem
public class CanvasItem
FormItem which renders a Canvas inline in a DynamicForm instance.
CanvasItem is shouldSaveValue:false by default, meaning that no
value from the CanvasItem will be present in values and no value will be saved when DynamicForm.saveData is called. This is appropriate if your
Canvas does not participate in displaying or editing the values of the form and is embedded in the form for layout
purposes only.
If you set shouldSaveValue:true, CanvasItem.showValue will be called to provide a value that your item should display. Implement
showValue() and call methods on the Canvas you've created to cause the value to be displayed.
showValue() will be called in various situations where the form receives data, including a call to DynamicForm.setValues, DynamicForm.editRecord, or if DynamicForm.fetchData is called and a Record is returned. Bear
in mind that showValue() can be called when the form and your item have not yet been drawn; in this case,
store the value for later display.
To provide a value to the form, call CanvasItem.storeValue whenever the user changes the value
in your Canvas. Note that the form will not call canvasItem.getValue() in order to discover your
item's value, so there is no purpose in overriding this method - use storeValue to proactively inform the
form about changes instead. This approach is necessary in order to enable change events.
If you cannot easily
detect changes to values in your Canvas, a workaround is to call storeValue right before the form saves.
| Field Summary |
|---|
| Fields inherited from class com.smartgwt.client.core.JsObject |
|---|
jsObj |
| Constructor Summary | |
|---|---|
CanvasItem()
|
|
CanvasItem(JavaScriptObject jsObj)
|
|
CanvasItem(String name)
|
|
CanvasItem(String name,
String title)
|
|
| Method Summary | |
|---|---|
HandlerRegistration |
addShowValueHandler(ShowValueHandler handler)
Add a showValue handler. |
Boolean |
canEditCriterion(Criterion criterion)
AdvancedCriteria objects may be edited via nested dynamicForms as described in CanvasItem.getCriterion |
protected Canvas |
createCanvas()
This method is called to dynamically create a canvas for this CanvasItem. |
Boolean |
getApplyPromptToCanvas()
If prompt is specified for this item, should the
prompt be applied to the canvas for this item? |
Canvas |
getCanvas()
The canvas that will be displayed inside this item. |
Criterion |
getCriterion()
The standard formItem criteria editing APIs have been overridden in the canvasItem class to simplify the editing of complex AdvancedCriteria objects using nested
DynamicForms. |
Boolean |
getEditCriteriaInInnerForm()
Flag to disable the criteria editing overrides described in CanvasItem.getCriterion whereby if this item contains a
DynamicForm as its canvas, it will be used to edit nested AdvancedCriteria automatically. |
static CanvasItem |
getOrCreateRef(JavaScriptObject jsObj)
|
Overflow |
getOverflow()
CanvasItems support specifying overflow for the Canvas directly on the item. |
String |
getPrompt()
This text is shown as a tooltip prompt when the cursor hovers over this item. |
Boolean |
getShouldSaveValue()
Should this item's value be saved in the form's values and hence returned from form.getValues()? |
Boolean |
hasAdvancedCriteria()
Overridden to return true if canvas is a
dynamicForm. |
void |
setApplyPromptToCanvas(Boolean applyPromptToCanvas)
If prompt is specified for this item, should the
prompt be applied to the canvas for this item? |
void |
setCanvas(Canvas canvas)
The canvas that will be displayed inside this item. |
void |
setCriterion(Criterion criterion)
Display a Criterion object in this item for editing. |
void |
setEditCriteriaInInnerForm(Boolean editCriteriaInInnerForm)
Flag to disable the criteria editing overrides described in CanvasItem.getCriterion whereby if this item contains a
DynamicForm as its canvas, it will be used to edit nested AdvancedCriteria automatically. |
void |
setOverflow(Overflow overflow)
CanvasItems support specifying overflow for the Canvas directly on the item. |
void |
setPrompt(String prompt)
This text is shown as a tooltip prompt when the cursor hovers over this item. |
void |
setShouldSaveValue(Boolean shouldSaveValue)
Should this item's value be saved in the form's values and hence returned from form.getValues()? |
protected void |
setupCanvasConstructor()
|
void |
storeValue(Object value)
Store a value for this form item. |
void |
storeValue(Record value)
Store a value for this form item. |
void |
storeValue(RecordList value)
Store a value for this form item. |
| Methods inherited from class com.smartgwt.client.core.RefDataClass |
|---|
getRef, getRef |
| Methods inherited from class com.smartgwt.client.core.DataClass |
|---|
doAddHandler, fireEvent, getAttributeAsDoubleArray, getAttributeAsIntArray, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute |
| Methods inherited from class com.smartgwt.client.core.JsObject |
|---|
setJsObj |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
|---|
fireEvent |
| Constructor Detail |
|---|
public CanvasItem()
public CanvasItem(JavaScriptObject jsObj)
public CanvasItem(String name)
public CanvasItem(String name,
String title)
| Method Detail |
|---|
public static CanvasItem getOrCreateRef(JavaScriptObject jsObj)
public void setApplyPromptToCanvas(Boolean applyPromptToCanvas)
prompt is specified for this item, should the
prompt be applied to the canvas for this item?
applyPromptToCanvas - applyPromptToCanvas Default value is truepublic Boolean getApplyPromptToCanvas()
prompt is specified for this item, should the
prompt be applied to the canvas for this item?
public void setCanvas(Canvas canvas)
CanvasItem.createCanvas to dynamically create the canvas when the FormItem is initialized. If canvas
and createCanvas() are unspecified, the canvas for this item will be auto-created using the overrideable
defaults: canvasProperties and canvasConstructor
Note that canvasItem will be set on the canvas to point back to this item.
canvas - canvas Default value is nullpublic Canvas getCanvas()
CanvasItem.createCanvas to dynamically create the canvas when the FormItem is initialized. If canvas
and createCanvas() are unspecified, the canvas for this item will be auto-created using the overrideable
defaults: canvasProperties and canvasConstructor
Note that canvasItem will be set on the canvas to point back to this item.
public void setEditCriteriaInInnerForm(Boolean editCriteriaInInnerForm)
CanvasItem.getCriterion whereby if this item contains a
DynamicForm as its canvas, it will be used to edit nested AdvancedCriteria automatically. This flag is required for cases where a canvasItem contains a DynamicForm, but the form is not set up to show inner field values of nested objects, and therefore should not attempt to apply nested advanced criteria directly to the form.
Note : This is an advanced setting
editCriteriaInInnerForm - editCriteriaInInnerForm Default value is truepublic Boolean getEditCriteriaInInnerForm()
CanvasItem.getCriterion whereby if this item contains a
DynamicForm as its canvas, it will be used to edit nested AdvancedCriteria automatically. This flag is required for cases where a canvasItem contains a DynamicForm, but the form is not set up to show inner field values of nested objects, and therefore should not attempt to apply nested advanced criteria directly to the form.
public void setOverflow(Overflow overflow)
overflow - overflow Default value is nullpublic Overflow getOverflow()
public void setPrompt(String prompt)
prompt for this item. Default implementation will also apply the prompt to canvas if applyPromptToCanvas is true.
setPrompt in class FormItemprompt - new prompt for the item.. Default value is nullBasics overview and related methodspublic String getPrompt()
getPrompt in class FormItemBasics overview and related methodspublic void setShouldSaveValue(Boolean shouldSaveValue)
form.getValues()? See the CanvasItem class overview for a discussion of values-handling in CanvasItems
setShouldSaveValue in class FormItemshouldSaveValue - shouldSaveValue Default value is falsepublic Boolean getShouldSaveValue()
form.getValues()? See the CanvasItem class overview for a discussion of values-handling in CanvasItems
getShouldSaveValue in class FormItempublic Boolean canEditCriterion(Criterion criterion)
CanvasItem.getCriterion This method has been
overridden to return true if this item's canvas is a DynamicForm, where the operator matches the operator of the criterion passed in and
dynamicForm contains items where FormItem.canEditCriterion returns true for each sub-criterion in the object passed in.
canEditCriterion in class FormItemcriterion - criteria to test
CriteriaEditing overview and related methodspublic Criterion getCriterion()
AdvancedCriteria objects using nested
DynamicForms.
The following pattern is supported without need for further modification:
A complex Advanced criteria object may have nested sub criteria using the "and"
or "or" operators. For example:
{ _constructor:"AdvancedCriteria",
operator:"and",
criteria:[
{fieldName:"field1", value:"value1", operator:"iContains"},
{operator:"or", criteria:[
{fieldName:"innerField1", value:"value1", operator:"equals"},
{fieldName:"innerField2", value:"value2", operator:"iContains"}
]
}
]
}
To create a form capable of editing the above criteria without providing custom overrides
to FormItem.getCriterion et al, you would create a
form with 2 items.
The 'field1' criterion could be edited by a simple form item such as a TextItem.
The nested criteria ('innerField1' and 'innerField2') could be edited by a canvasItem
whose canvas property was set to a DynamicForm showing items capable of editing the 2
inner criteria, and whose operator was specified as "or".
isc.DynamicForm.create({
items:[
{name:"field1", type:"TextItem"},
{name:"nestedItem", shouldSaveValue:true, type:"CanvasItem",
canvas:isc.DynamicForm.create({
operator:"or",
items:[
{name:"innerField1", type:"TextItem", operator:"equals"},
{name:"innerField2", type:"TextItem"}
]
})
}
]
});
This form would be able to edit the above advanced criteria object via
DynamicForm.setValuesAsCriteria. Edited values
would be retrieved via
DynamicForm.getValuesAsCriteria.
Note that the canvas item has shouldSaveValue set to true - this is required
to ensure the nested form is actually passed the values to edit.
The default implementation of this method checks for this.canvas being specified as a
dynamicForm, and in that case simply returns the result of
DynamicForm.getValuesAsAdvancedCriteria
on the inner form.
Note that this functionality may be entirely bypassed by
setting editCriteriaInInnerForm to
false. This flag is useful when defining a
dynamicForm based canvasItem which is not intended for editing nested data -- for example
if a standard atomic field value is being displayed in some custom way using a
DynamicForm embedded in the item.
getCriterion in class FormItemDynamicForm.getValuesAsCriteriaCriteriaEditing overview and related methodspublic Boolean hasAdvancedCriteria()
canvas is a
dynamicForm. See CanvasItem.getCriterion for
details of editing advanced criteria using nested dynamicForms.
hasAdvancedCriteria in class FormItemCriteriaEditing overview and related methodspublic void setCriterion(Criterion criterion)
Criterion object in this item for editing. Overridden from FormItem.setCriterion in order to support editing nested
criteria using nested dynamicForms as described in CanvasItem.getCriterion. Implementation checks for this.canvas being specified as a DynamicForm, and applies criterion directly to the embedded form via setValuesAsCriteria()
setCriterion in class FormItemcriterion - criteria to editpublic HandlerRegistration addShowValueHandler(ShowValueHandler handler)
This method will be called whenever this form item's value is being set via a programmatic call to e.g: DynamicForm.setValues or FormItem.setValue and may be overridden by CanvasItems
intended to support displaying data values to update the embedded Canvas to reflect the value passed in.
addShowValueHandler in interface HasShowValueHandlershandler - the showValue handler
HandlerRegistration used to remove this handlerprotected void setupCanvasConstructor()
protected Canvas createCanvas()
#setCanvas() directly.
public void storeValue(Object value)
FormItem.change and FormItem.changed handlers, and store out the method
passed in such that subsequent calls to FormItem.getValue or DynamicForm.getValue will return the
new value for this item. For canvasItems that manipulate values and display them in some arbitrary canvas representation developers should call this method when the user interacts with the embedded canvas in a way that modifies the value for the item.
If you cannot easily detect changes to values in your Canvas, a workaround is to
call storeValue right before the form saves.
value - value to save for this itempublic void storeValue(Record value)
FormItem.change and FormItem.changed handlers, and store out the method
passed in such that subsequent calls to FormItem.getValue or DynamicForm.getValue will return the
new value for this item. For canvasItems that manipulate values and display them in some arbitrary canvas representation developers should call this method when the user interacts with the embedded canvas in a way that modifies the value for the item.
If you cannot easily detect changes to values in your Canvas, a workaround is to
call storeValue right before the form saves.
value - value to save for this itempublic void storeValue(RecordList value)
FormItem.change and FormItem.changed handlers, and store out the method
passed in such that subsequent calls to FormItem.getValue or DynamicForm.getValue will return the
new value for this item. For canvasItems that manipulate values and display them in some arbitrary canvas representation developers should call this method when the user interacts with the embedded canvas in a way that modifies the value for the item.
If you cannot easily detect changes to values in your Canvas, a workaround is to
call storeValue right before the form saves.
value - value to save for this item
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||