com.wewebu.ow.server.dmsdialogs.views
Class OwObjectPropertyFormularView

java.lang.Object
  extended by com.wewebu.ow.server.ui.OwEventTarget
      extended by com.wewebu.ow.server.ui.OwView
          extended by com.wewebu.ow.server.dmsdialogs.views.OwObjectPropertyFormularView
All Implemented Interfaces:
OwFieldProvider, OwBaseView, OwJspConfigurable, OwUpdateTarget

public class OwObjectPropertyFormularView
extends OwView
implements OwFieldProvider, OwJspConfigurable

Form View for Object Properties. Can take JSP or HTML based forms.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Nested Class Summary
 class OwObjectPropertyFormularView.OwPropertyPlaceholder
          tuple after a successful placeholder scan
 
Field Summary
protected  boolean m_enablesaveall
          Flag to enable save all button option when more than one documents are selected.
The save all button will be rendered if this m_saveAllActive is set to true, the m_enablesaveall is set to true and OwObjectPropertyFormView.isReadOnly flag is false.
protected  int m_iSaveButton
          index of the save button
protected  OwPasteMetadataHandler m_pasteMetadataHandler
          paste metadata handler
protected  OwPropertyCollection m_properties
          the properties from the work item
protected  boolean m_saveAllActive
          flag specify if save all feature is active
protected  int m_saveAllButtonIndex
          save all button index
protected  OwFieldManager m_theFieldManager
          instance of the property field class
 
Fields inherited from class com.wewebu.ow.server.ui.OwView
CURRENT_MODULE_KEY, FORMULAR_PLACEHOLDER_END_DELIMITER, FORMULAR_PLACEHOLDER_START_DELIMITER, m_externalFormEventTarget
 
Fields inherited from interface com.wewebu.ow.server.field.OwFieldProvider
TYPE_AJAX, TYPE_CHECKIN_OBJECT, TYPE_CREATE_OBJECT, TYPE_META_OBJECT, TYPE_RESULT_LIST, TYPE_SEARCH, TYPE_SMALL
 
Fields inherited from interface com.wewebu.ow.server.ui.OwBaseView
EMPTY_STRING
 
Constructor Summary
OwObjectPropertyFormularView()
           
 
Method Summary
protected  void addSaveAllButton(String saveAllText_p)
          Add Save All button
protected  void changeSaveAllButtonState()
          Establish the enabled state for saveAll button
protected  OwBatchPropertiesHandler createBatchPropertiesHandler()
          Creates the batch properties handler
protected  OwPasteMetadataHandler createPasteMetadataHandler()
          Create a OwPasteMetadataHandler object
 void detach()
          remove view and all subviews from context
 boolean displayNoSaveMsg()
          Display "no save" message.
 void filterProperties(Collection<OwObjectPropertyView.OwPropertyInfo> propertyInfos_p)
          Filter properties based on provided collection.
 OwField getField(String strFieldClassName_p)
          implementation for the OwFieldProvider interface
 OwFieldManager getFieldManager()
          get a reference to the internal field manager
 String getFieldProviderName()
          get a name that identifies the field provider
 Object getFieldProviderSource()
          get the source object that originally provided the fields.
 int getFieldProviderType()
          implementation for the OwFieldProvider interface get the type of field provider as defined with TYPE_...
 Collection getFields()
          get all the properties in the form
 OwJspFormConfigurator getJspConfigurator()
          Get the associated OwJspFormConfigurator object.
 OwMenuView getMenu()
          get the menu
 OwObject getObjectRef()
          get the current object to use for property rendering
protected  int getReadOnlyContext()
          get context to be used for the read-only property
 Object getSafeFieldValue(String sName_p, Object defaultvalue_p)
          retrieve the value of a Field
protected  int getSaveBtnIndex()
          get the index of the save button
 boolean getUpdateStatus()
          get the status after the last update
protected  void informUserOnSuccess()
          Post a message for informing user about a successfully save operation.
protected  void init()
          init the target after the context is set.
 boolean isFieldMandatory(String strPlaceHolder_p)
          Checks if a field is mandatory or not.
 boolean isNamedRegion(String strRegion_p)
          determine if region exists
 boolean isPasteMetadataActivated()
          Get the status of "paste metadata" feature.
 boolean isReadOnly()
           
 boolean isSystemPropertyView()
          Always returns false.
 void onBatchIndex()
          Update the specified properties (from owplugins->EditBatchPropertyList) with the values from previous view.
 void onPasteAllMetaData(javax.servlet.http.HttpServletRequest request_p)
          called when user presses the paste all metadata button
 void onPasteThisMetaData(javax.servlet.http.HttpServletRequest request_p)
          called when user presses the paste this metadata button
protected  void onRender(Writer w_p)
          called when the view should create its HTML content to be displayed
 boolean onSave(javax.servlet.http.HttpServletRequest request_p, Object oReason_p)
          called when the user wants to save the modified properties call getUpdateStatus() after save to check if fields are invalid
protected  boolean onSaveInternal(javax.servlet.http.HttpServletRequest request_p, Object oReason_p)
          called to save the modified properties call getUpdateStatus() after save to check if fields are invalid
protected  void renderMenuRegion(Writer w_p)
          render the menu region
 void renderNamedRegion(Writer w_p, String strPlaceHolder_p)
          Called when the form parser finds a placeholder in the HTML / JSP input
 void renderPasteAll(Writer w_p)
          Utility method to render "paste all" symbol.
 void renderPasteProperty(Writer w_p, String propName_p)
          Utility method to render "paste" symbol.
protected  void renderProperty(Writer w_p, OwProperty prop_p, boolean fReadOnly_p)
          overridable to render a property
protected  boolean save(OwPropertyCollection changedProperties_p)
          save the properties to the object
 void setBatchProperties(Collection batchIndexProperties_p)
          Set the collection of property names for batch feature.
 void setDisplayNoSaveMsg(boolean display_p)
          Set the flag if "no save" message(s) should be displayed or not.
 void setField(String sName_p, Object value_p)
          modify a Field value, but does not save the value right away
 void setHTMLFormular(String strHTMLPage_p)
          set the JSP page to use as a form
 void setJspConfigurator(OwJspFormConfigurator jspFormConfigurator_p)
          Set the associated OwJspFormConfigurator object.
 void setJspFormular(String strJspPage_p)
          set the optional JSP form to use in the render method

In the JSP Form you can use the following statements to display and manipulate Properties

// get a reference to the calling view
OwView m_View = (OwView)request.getAttribute(OwView.CURRENT_MODULE_KEY);

<% m_View.renderNamedRegion(out,); %> : renders the Property FieldName
<% m_View.renderNamedRegion(out,ow_err_); %> : renders any validation error messages for the Property FieldName
<% m_View.renderNamedRegion(out,ow_ro_); %> : renders the Property FieldName always read-only
<% m_View.renderNamedRegion(out,ow_menu); %> : renders a function menu to save changes


You can also cast the m_View to OwFieldProvider to retrieve a OwField instance and manipulate or program a field directly.
 void setObjectRef(OwObject objectRef_p)
           
 void setPasteMetadataEnabled(boolean enabled_p)
          Set the enabled status for paste metadata feature.
 void setReadOnlyContext(int context_p)
          set context to be used for the read-only property
 void setSaveAllActive(boolean saveAllEnabled_p)
          Setter for saveAll button state.
protected  OwPropertyCollection update(javax.servlet.http.HttpServletRequest request_p)
          update view from request to save the changes call save
 boolean updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p, boolean fSave_p)
          update the target after a form event, so it can set its form fields
protected  String usesFormWithAttributes()
          to get additional form attributes used for the form override if your view needs a form.
 
Methods inherited from class com.wewebu.ow.server.ui.OwView
activate, addView, getBreadcrumbPart, getDocument, getExternalFormEventTarget, getFormName, getFormTarget, getIcon, getIterator, getMaximizeView, getParent, getRenderedNamedRegion, getRenderedRegion, getTitle, getViewList, isFormTargetExternal, isRegion, isShowMaximized, isShowMinimized, isShowNormal, onActivate, onUpdate, render, renderHTMLFormular, renderRegion, serverSideDesignInclude, serverSideInclude, setDocument, setExternalFormTarget, setMaximizeView, setParent, showMaximized, showMinimized, showNormal
 
Methods inherited from class com.wewebu.ow.server.ui.OwEventTarget
attach, disableRequestListener, enableRequestListener, getAjaxEventURL, getContext, getEventURL, getFormEventFunction, getFormEventURL, getID, onExternalRequest, onFormEvent, onRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_enablesaveall

protected boolean m_enablesaveall
Flag to enable save all button option when more than one documents are selected.
The save all button will be rendered if this m_saveAllActive is set to true, the m_enablesaveall is set to true and OwObjectPropertyFormView.isReadOnly flag is false.

Since:
3.1.0.0

m_iSaveButton

protected int m_iSaveButton
index of the save button


m_pasteMetadataHandler

protected OwPasteMetadataHandler m_pasteMetadataHandler
paste metadata handler


m_properties

protected OwPropertyCollection m_properties
the properties from the work item


m_saveAllActive

protected boolean m_saveAllActive
flag specify if save all feature is active

Since:
3.1.0.0

m_saveAllButtonIndex

protected int m_saveAllButtonIndex
save all button index


m_theFieldManager

protected OwFieldManager m_theFieldManager
instance of the property field class

Constructor Detail

OwObjectPropertyFormularView

public OwObjectPropertyFormularView()
Method Detail

addSaveAllButton

protected void addSaveAllButton(String saveAllText_p)
                         throws Exception
Add Save All button

Parameters:
saveAllText_p - - the text to be displayed in the button
Throws:
Exception

changeSaveAllButtonState

protected void changeSaveAllButtonState()
Establish the enabled state for saveAll button

Since:
3.1.0.0

createBatchPropertiesHandler

protected OwBatchPropertiesHandler createBatchPropertiesHandler()
Creates the batch properties handler

Returns:
an OwBatchPropertiesHandler object
Since:
3.1.0.0

createPasteMetadataHandler

protected OwPasteMetadataHandler createPasteMetadataHandler()
Create a OwPasteMetadataHandler object

Returns:
the newly created handler
Since:
3.1.0.0

detach

public void detach()
remove view and all subviews from context

Overrides:
detach in class OwView

displayNoSaveMsg

public boolean displayNoSaveMsg()
Display "no save" message. By default this flag is set to false.

Returns:
boolean flag
Since:
3.1.0.3
See Also:
setDisplayNoSaveMsg(boolean)

filterProperties

public void filterProperties(Collection<OwObjectPropertyView.OwPropertyInfo> propertyInfos_p)
                      throws Exception
Filter properties based on provided collection.

Parameters:
propertyInfos_p - - can be null - no filter is applied.
Throws:
Exception

getField

public OwField getField(String strFieldClassName_p)
                 throws Exception
implementation for the OwFieldProvider interface

Specified by:
getField in interface OwFieldProvider
Parameters:
strFieldClassName_p - String class name of requested fields
Returns:
OwField or throws OwObjectNotFoundException
Throws:
Exception

getFieldManager

public OwFieldManager getFieldManager()
get a reference to the internal field manager


getFieldProviderName

public String getFieldProviderName()
get a name that identifies the field provider

Specified by:
getFieldProviderName in interface OwFieldProvider
Returns:
String unique ID / Name of fieldprovider

getFieldProviderSource

public Object getFieldProviderSource()
get the source object that originally provided the fields. e.g. the fieldprovider might be a template pattern implementation like a view, where the original provider would still be an OwObject

Specified by:
getFieldProviderSource in interface OwFieldProvider
Returns:
Object the original source object where the fields have been taken, can be a this pointer

getFieldProviderType

public int getFieldProviderType()
implementation for the OwFieldProvider interface get the type of field provider as defined with TYPE_...

Specified by:
getFieldProviderType in interface OwFieldProvider

getFields

public Collection getFields()
                     throws Exception
get all the properties in the form

Specified by:
getFields in interface OwFieldProvider
Returns:
Collection of OwField
Throws:
Exception

getJspConfigurator

public OwJspFormConfigurator getJspConfigurator()
Description copied from interface: OwJspConfigurable
Get the associated OwJspFormConfigurator object. Can be null.

Specified by:
getJspConfigurator in interface OwJspConfigurable
Returns:
the associated OwJspFormConfigurator object or null.

getMenu

public OwMenuView getMenu()
get the menu


getObjectRef

public OwObject getObjectRef()
get the current object to use for property rendering

Returns:
OwObject

getReadOnlyContext

protected int getReadOnlyContext()
get context to be used for the read-only property

Returns:
context_p int as defined with OwPropertyClass.CONTEXT_...

getSafeFieldValue

public Object getSafeFieldValue(String sName_p,
                                Object defaultvalue_p)
retrieve the value of a Field

Specified by:
getSafeFieldValue in interface OwFieldProvider
Parameters:
sName_p -
defaultvalue_p -
Returns:
Object the value of the Field of defaultvalue_p

getSaveBtnIndex

protected int getSaveBtnIndex()
get the index of the save button


getUpdateStatus

public boolean getUpdateStatus()
get the status after the last update

Returns:
boolean true = update was OK, all fields are valid, false = update caused errors, one or more fields are invalid

informUserOnSuccess

protected void informUserOnSuccess()
Post a message for informing user about a successfully save operation.

Since:
3.1.0.0

init

protected void init()
             throws Exception
init the target after the context is set.

Overrides:
init in class OwView
Throws:
Exception

isNamedRegion

public boolean isNamedRegion(String strRegion_p)
                      throws Exception
determine if region exists

Specified by:
isNamedRegion in interface OwBaseView
Overrides:
isNamedRegion in class OwView
Parameters:
strRegion_p - name of the region to render of the following form: [ow_err_ | ow_ro_][.] e.g.: Customer : renders the property "Customer" ow_err_Customer : renders the error string for the property "Customer" ow_ro_Custpmer : renders the property "Customer" as read-only Customer.Address : renders the property "Address" of the property "Customer", if Customer is of type OwObject
Returns:
true if region contains anything and should be rendered
Throws:
Exception

isPasteMetadataActivated

public boolean isPasteMetadataActivated()
Get the status of "paste metadata" feature.

Returns:
-true if the JSP should render the Paste All and Paste buttons.
Since:
3.1.0.0.

isReadOnly

public boolean isReadOnly()

isSystemPropertyView

public boolean isSystemPropertyView()
Always returns false.

Returns:
false
Since:
3.1.0.0

onBatchIndex

public void onBatchIndex()
                  throws Exception
Update the specified properties (from owplugins->EditBatchPropertyList) with the values from previous view.

Throws:
Exception

onPasteAllMetaData

public void onPasteAllMetaData(javax.servlet.http.HttpServletRequest request_p)
                        throws Exception
called when user presses the paste all metadata button

Throws:
Exception
Since:
3.1.0.0

onPasteThisMetaData

public void onPasteThisMetaData(javax.servlet.http.HttpServletRequest request_p)
                         throws Exception
called when user presses the paste this metadata button

Throws:
Exception
Since:
3.1.0.0

onRender

protected void onRender(Writer w_p)
                 throws IOException,
                        Exception
called when the view should create its HTML content to be displayed

Overrides:
onRender in class OwView
Parameters:
w_p - Writer object to write HTML to
Throws:
Exception
IOException

onSave

public boolean onSave(javax.servlet.http.HttpServletRequest request_p,
                      Object oReason_p)
               throws Exception
called when the user wants to save the modified properties call getUpdateStatus() after save to check if fields are invalid

Returns:
true = fields have been saved, false = nothing has been saved
Throws:
Exception

onSaveInternal

protected boolean onSaveInternal(javax.servlet.http.HttpServletRequest request_p,
                                 Object oReason_p)
                          throws Exception
called to save the modified properties call getUpdateStatus() after save to check if fields are invalid

Returns:
true = fields have been saved, false = nothing has been saved
Throws:
Exception

renderMenuRegion

protected void renderMenuRegion(Writer w_p)
                         throws Exception
render the menu region

Throws:
Exception

isFieldMandatory

public boolean isFieldMandatory(String strPlaceHolder_p)
                         throws Exception
Checks if a field is mandatory or not.

Parameters:
strPlaceHolder_p - The name of the field (usually this is the same with the name of the property). It has to be a fully qualified name (include the name of the class too);
Returns:
true if this field is mandatory
Throws:
Exception
Since:
4.2.0.0
See Also:
renderNamedRegion(Writer, String)

renderNamedRegion

public void renderNamedRegion(Writer w_p,
                              String strPlaceHolder_p)
                       throws Exception
Called when the form parser finds a placeholder in the HTML / JSP input

Specified by:
renderNamedRegion in interface OwBaseView
Overrides:
renderNamedRegion in class OwView
Parameters:
strPlaceHolder_p - the placeholder string found of the following form: [ow_err_ | ow_ro_][.] e.g.: Customer : renders the property "Customer" ow_err_Customer : renders the error string for the property "Customer" ow_ro_Customer : renders the property "Customer" as read-only Customer.Address : renders the property "Address" of the property "Customer", if Customer is of type OwObject
w_p - Writer object, write to replace placeholder
Throws:
Exception

renderPasteAll

public void renderPasteAll(Writer w_p)
                    throws Exception
Utility method to render "paste all" symbol.

Parameters:
w_p - - the Writer object
Throws:
Exception
Since:
3.1.0.0

renderPasteProperty

public void renderPasteProperty(Writer w_p,
                                String propName_p)
                         throws Exception
Utility method to render "paste" symbol.

Parameters:
w_p - - Writer object
propName_p - - the name of the property
Throws:
Exception
Since:
3.1.0.0

renderProperty

protected void renderProperty(Writer w_p,
                              OwProperty prop_p,
                              boolean fReadOnly_p)
                       throws Exception
overridable to render a property

Throws:
Exception

save

protected boolean save(OwPropertyCollection changedProperties_p)
                throws Exception
save the properties to the object

Parameters:
changedProperties_p - OwPropertyCollection see update
Returns:
true = fields have been saved, false = nothing has been saved
Throws:
Exception

setBatchProperties

public void setBatchProperties(Collection batchIndexProperties_p)
Set the collection of property names for batch feature.

Parameters:
batchIndexProperties_p -
Since:
3.0.0.0

setDisplayNoSaveMsg

public void setDisplayNoSaveMsg(boolean display_p)
Set the flag if "no save" message(s) should be displayed or not.

Parameters:
display_p - boolean flag
Since:
3.1.0.3

setField

public void setField(String sName_p,
                     Object value_p)
              throws Exception,
                     OwObjectNotFoundException
modify a Field value, but does not save the value right away

Specified by:
setField in interface OwFieldProvider
Parameters:
sName_p -
value_p -
Throws:
Exception
OwObjectNotFoundException

setHTMLFormular

public void setHTMLFormular(String strHTMLPage_p)
set the JSP page to use as a form


setJspConfigurator

public void setJspConfigurator(OwJspFormConfigurator jspFormConfigurator_p)
Description copied from interface: OwJspConfigurable
Set the associated OwJspFormConfigurator object. Can be null.

Specified by:
setJspConfigurator in interface OwJspConfigurable

setJspFormular

public void setJspFormular(String strJspPage_p)
                    throws Exception
set the optional JSP form to use in the render method

In the JSP Form you can use the following statements to display and manipulate Properties

// get a reference to the calling view
OwView m_View = (OwView)request.getAttribute(OwView.CURRENT_MODULE_KEY);

<% m_View.renderNamedRegion(out,); %> : renders the Property FieldName
<% m_View.renderNamedRegion(out,ow_err_); %> : renders any validation error messages for the Property FieldName
<% m_View.renderNamedRegion(out,ow_ro_); %> : renders the Property FieldName always read-only
<% m_View.renderNamedRegion(out,ow_menu); %> : renders a function menu to save changes


You can also cast the m_View to OwFieldProvider to retrieve a OwField instance and manipulate or program a field directly.

Parameters:
strJspPage_p -
Throws:
Exception

setObjectRef

public void setObjectRef(OwObject objectRef_p)
                  throws Exception
Parameters:
objectRef_p - The objectRef to set.
Throws:
Exception

setPasteMetadataEnabled

public void setPasteMetadataEnabled(boolean enabled_p)
Set the enabled status for paste metadata feature.

Parameters:
enabled_p -
Since:
3.1.0.0

setReadOnlyContext

public void setReadOnlyContext(int context_p)
set context to be used for the read-only property

Parameters:
context_p - int as defined with OwPropertyClass.CONTEXT_...

setSaveAllActive

public void setSaveAllActive(boolean saveAllEnabled_p)
Setter for saveAll button state.

Parameters:
saveAllEnabled_p -
Since:
3.1.0.0

update

protected OwPropertyCollection update(javax.servlet.http.HttpServletRequest request_p)
                               throws Exception
update view from request to save the changes call save

Returns:
OwPropertyCollection
Throws:
Exception

updateExternalFormTarget

public boolean updateExternalFormTarget(javax.servlet.http.HttpServletRequest request_p,
                                        boolean fSave_p)
                                 throws Exception
update the target after a form event, so it can set its form fields

Overrides:
updateExternalFormTarget in class OwEventTarget
Parameters:
request_p - HttpServletRequest
fSave_p - boolean true = save the changes of the form data, false = just update the form data, but do not save
Returns:
true = field data was valid, false = field data was invalid
Throws:
Exception

usesFormWithAttributes

protected String usesFormWithAttributes()
to get additional form attributes used for the form override if your view needs a form. Base class will then render a form automatically

Overrides:
usesFormWithAttributes in class OwView
Returns:
String with form attributes, or null if view does not render a form


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.