Use remote actions
Remote actions trigger actions from the Web Content Manager application. We reference remote actions using plugin tags...
[plugin:RemoteAction action=" " doc dialog=" " dialogSize=" " dialogTitle=" " useCurrentContext=" " showInfoMsg=" " ]
action Remote action to perform. docid Document ID of the item to run the remote action against. useCurrentContext If true, the document ID is obtained form the rendering context instead of the docid attribute. dialog If true, when rendered within a Web Content Viewer portlet, the remote action is rendered as a URL that redirects the user to a hidden portal page used by the Web Content Viewer portlet for inline editing. dialogSize Defines the size of the dialog executing the remote action. The value must be in the format "width,height". Optional. dialogSize="200,300"
...for a dialog of width 200 pixel and a height of 300 pixel. If omitted, the dialog size is calculated from the content displayed in the dialog. This setting is only used if dialog="true".
dialogTitle Optional. Set the title of the dialog executing the remote action. If omitted, the action name is used instead. This setting is only used if dialog="true". showInfoMsg Set true to display success status and other information messages after the remote action has finished. If omitted, default is false. Only warning and error status messages are displayed. Can only be used if dialog="true".
Remote actions can also be appended to the URL of an authoring portlet.
http://[host]/wps/myportal/wcmAuthoring?wcmAuthoringAction=action
We can also append remote actions to the URL of a local Web Content Viewer portlet. This can be useful in sites that feature inline editing of content items.
Remote actions are not intended to be used to create a custom authoring interface. There are limitations to the functionality delivered using remote actions. Remote actions only support plain text. We cannot use remote actions to add markup into elements such as HTML elements. Instead, use the WCM API to create custom authoring interfaces.
Each web content item can be identified by a DocumentId. The "docid" can be retrieved using the web content API. In the following examples, the value of the "docid" parameter should be the DocumentId as retrieved using the method...
DocumentID.getID()
A document ID consists of a document type and a unique ID. The "docid" values provided in the examples are placeholders for real document IDs.
com.ibm.workplace.wcm.api.WCM_Content/ID1
Remote action types
new Open a new item form. [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content"]
The following type parameters can be used:
- com.ibm.workplace.wcm.api.WCM_AuthoringTemplate
- com.ibm.workplace.wcm.api.WCM_Category
- com.ibm.workplace.wcm.api.WCM_Content
- com.ibm.workplace.wcm.api.WCM_DateComponent
- com.ibm.workplace.wcm.api.WCM_FileComponent
- com.ibm.workplace.wcm.api.WCM_HTMLComponent
- com.ibm.workplace.wcm.api.WCM_ImageComponent
- com.ibm.workplace.wcm.api.WCM_NumericComponent
- com.ibm.workplace.wcm.api.WCM_PresentationTemplate
- com.ibm.workplace.wcm.api.WCM_RichTextComponent
- com.ibm.workplace.wcm.api.WCM_ShortTextComponent
- com.ibm.workplace.wcm.api.WCM_SiteArea
- com.ibm.workplace.wcm.api.WCM_Taxonomy
- com.ibm.workplace.wcm.api.WCM_TextComponent
- com.ibm.workplace.wcm.api.WCM_Workflow
- com.ibm.workplace.wcm.api.WCM_WorkflowStage
When creating a new content item, we can specify a default authoring template by providing the document ID of the authoring template in the atid parameter:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" at]
When creating site areas, content items and categories, we can specify the document ID of the parent item to save the new item under. Specify this ID in the pid parameter:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" p] [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_SiteArea" p] [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Category" p]
When creating site areas we can specify the position of the new site area using a position parameter. We can specify to save the new site area at the start or end relative to any existing site areas. If not specified, the new site area will be saved at the start relative to any existing site areas:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" position="start"] [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_SiteArea" position="end"]
delete Delete an item. [plugin:RemoteAction action="delete" doc]
edit Open an item form in edit mode.
[plugin:RemoteAction action="edit" doc]
read Open an item form in read-only mode.
[plugin:RemoteAction action="read" doc]
openmainview Open a view within an authoring portlet. [plugin:RemoteAction action="openmainview" view="contentbysitearea"]
The following view parameters can be used:
- contentbysitearea
- contentbytitle
- myrecent
- mydraft
- mypendingapproval
- mypublished
- myexpired
- mydeleted
- alldraftitems
- allexpireditems
- allpublisheditems
- alldeleteditems
- componentsbytype
move This is used to move a site area or content item. To open the move dialog for a content item or site area:
[plugin:RemoteAction action="move" doc]
A move direction is specified as "1" for up and "-1" for down. To move a content item up one position:
[plugin:RemoteAction action="move" doc p moveDirection="1"]
link This will link a content item to a site area.
[plugin:RemoteAction action="link" doc p]
When linking items we can specify the path to the parent item using the ppath parameter instead of the pid parameter:
[plugin:RemoteAction action="link" doc ppath="library1/sitearea1/sitearea2"]
When linking items we can create a new parent item using the autoCreateParent parameter. We specify the library where the item being linked is located using the slibrary parameter. The ppath parameter specifies the existing parent the new parent item is created under:
[plugin:RemoteAction action="link" doc autoCreateParent="true" slibrary="libraryname" ppath="library1/sitearea1/sitearea2"]
copy Make a copy of an item. To copy a content item to a new site area:
[plugin:RemoteAction action="copy" doc p]
Use the following additional parameters when copying:
- copyAsDraft="true"
Restart the workflow of the copy being creating. In most cases this would result in the copy being created with a status of draft.
w
Specify a different workflow to use when creating the copy. This will also restart the workflow of the copy being creating. In most cases this would result in the copy being created with a status of draft.
- position="start"
This creates the copy as the first item under the specified parent item. If not specified the item will be copied as the last child of the specified parent item.
When copying items we can specify the path to the parent item using the ppath parameter instead of the pid parameter:
[plugin:RemoteAction action="copy" doc ppath="library1/sitearea1/sitearea2"]
When copying items we can create a new parent item using the autoCreateParent parameter. We specify the library where the item being copied is located using the slibrary parameter. The ppath parameter specifies the existing parent the new parent item is created under:
[plugin:RemoteAction action="copy" doc autoCreateParent="true" slibrary="libraryname" ppath="library1/sitearea1/sitearea2"]
approve Approve an item in a workflow.
[plugin:RemoteAction action="approve" doc]
decline Decline an item in a workflow.
[plugin:RemoteAction action="decline" doc]
saveandapprove Approve an item in a workflow where that item is currently open in edit mode within the same session.
[plugin:RemoteAction action="saveandapprove" doc] [plugin:RemoteAction action="saveandapprove" doc isdraft="true"]
previousstage Move an item to the previous stage in a workflow.
[plugin:RemoteAction action="previousstage" doc]
viewversions Open the versions dialog for an item.
[plugin:RemoteAction action="viewversions" doc]
viewhistory Open the history dialog for an item.
[plugin:RemoteAction action="viewhistory" doc]
Populating fields when creating or editing content
When using the "new" or "edit" parameters with content items, we can also add data to different fields in the content item using a URL. To add "newcontent" as the name of the content item, we would use this URL:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.name="newcontent"]
The following parameters can be used to populate fields when creating or editing content:
- wcmfield.content.name=
- wcmfield.content.title=
- wcmfield.content.description=
- wcmfield.content.authors=
- wcmfield.content.owners=
- wcmfield.content.publishDate=
- wcmfield.content.expiryDate=
- wcmfield.content.generalDateOne=
- wcmfield.content.generalDateTwo=
- wcmfield.content.workflow= (This can only be used when creating content.)
- wcmfield.content.categories=
- wcmfield.content.keywords=
- wcmfield.element.elementname=
You replace elementname with the name of the element we are populating. The element parameter can only be used with the following element types:
- Text
- Html
- Rich text
- Option Selection
- User Selection
- Date and time
- Number
- JSP
- Link
- Component Reference
When populating fields with user ids use this format:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.authors="uid=usera,cn=cn-name,dc=dc-name"]
When populating workflow and category fields use the document IDs as their values:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.workflow="ID1"] [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.categories="ID1"]
When populating date fields, the date format must be US English. Either a date and time, or just a date can be specified. If only a date is specified, the time used will be 12:00:00 AM. For example:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.generalDateOne="Feb 14, 2008 12:53:03 PM"] [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.generalDateOne="Feb 14, 2008"]
The date and time set here are based on the server's timezone, not the timezone of the user's computer.
When populating a JSP element, specify the path to the JSP file:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.jspelementname="/wps/wcm/jsp/html/example.jsp"]
When populating a component reference element, specified the component to reference. For example:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.mycompref.type="com.aptrix.pluto.cmpnt.NavigatorCmpnt" wcmfield.element.mycompref.]
When populating an option selection element, specify each selection option. For example:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.elementname="AA" wcmfield.element.elementname="BB"]
When populating a user selection element, specify each user. For example:
[plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.elementname="uid=wpsadmin,o=defaultWimFileBasedRealm" wcmfield.element.elementname="uid=wpsadmin2,o=defaultWimFileBasedRealm"]
When populating a Link element, we can specify the following parameters:
Add a link to a content item: [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.elementname.type="content" wcmfield.element.elementname.]Add a link to a link component: [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.elementname.type="link" wcmfield.element.elementname.]Add a link to an image or file resource component: [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.elementname.type="resource" wcmfield.element.elementname.]Add a link to a URL: [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.element.elementname.type="external" wcmfield.element.elementname.externalReference="myurl"]To specify whether to use the name of the item we are linking to as the link text, add this to the tag: wcmfield.element.elementname.useReferenceLinkText="true" When specifying an image to display as the link, add this to the tag: wcmfield.element.elementname.linkImage="imagecomponentID" When specifying the text of the link, add this to the URL: wcmfield.element.elementname.linkText="text" When specifying the description of the link, add this to the URL: wcmfield.element.elementname.linkDescription="text" When specifying a link target, add this to the URL: wcmfield.element.elementname.linkTarget=
- _blank
- _parent
- _self
- _top
- targetname
Save parameters
We can add the following "save" parameters to a remote action tag.
autoSave Save a controllable. This happens in the background and is not displayed to users. For example:
- wcmfield.autosave="true"
saveValidate This parameter determines if warning and error messages resulting from the autosave will be displayed to the user. If set to "true", warning and error messages will be displayed to the user. If false, messages are suppressed. The default is true. For example:
- &wcmfield.saveValidate="false"
Add comments to the item history
When creating items that use a workflow with "Enter comment on approval" set to true, we can add a comment to the item history by adding comment="comment text" to the URL. For example:
[plugin:RemoteAction action="edit" doc
createDraft="true" comment="comment text"]
Examples
Open the versions view for an item:
- Tag: [plugin:RemoteAction action="viewversions" doc]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=viewversions&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1
Open the history view for an item:
- Tag: [plugin:RemoteAction action="viewhistory" doc]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=viewhistory&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1
Open a content item in read mode:
- Tag: [plugin:RemoteAction action="read" doc]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=read&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1
Open a content item in edit mode:
- Tag: [plugin:RemoteAction action="edit" &docid=com.ibm.workplace.wcm.api.WCM_Content/ID1]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=edit&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1
Move a content item up:
- Tag: [plugin:RemoteAction action="move" doc moveDirection="1" p]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=move&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1&moveDirection=1&pid=com.ibm.workplace.wcm.api.WCM_SiteArea/ID1
Move a site area down:
- Tag: [plugin:RemoteAction action="move" doc "moveDirection="-1" p]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=move&docid=com.ibm.workplace.wcm.api.WCM_SiteArea/ID1&moveDirection=-1&pid=com.ibm.workplace.wcm.api.WCM_SiteArea/ID1
Create a new content item with title of 'newcontent':
- Tag: [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" wcmfield.content.]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=new&type=com.ibm.workplace.wcm.api.WCM_Content&wcmfield.content.title=newcontent
To open a content item in edit mode and automatically change keywords:
- Tag: [plugin:RemoteAction action="edit" doc wcmfield.content.keywords="keyword1" wcmfield.content.keywords="keyword2"]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=edit&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1&wcmfield.content.keywords=keyword1&wcmfield.content.keywords=keyword2
To edit a content item, automatically change the keywords and use autosave to automatically save the content (no dialog opens):
- Tag: [plugin:RemoteAction action="edit" doc wcmfield.content.keywords="keyword1" wcmfield.content.keywords="keyword2" wcmfield.autosave="true"]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=edit&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1&wcmfield.content.keywords=keyword1&wcmfield.content.keywords=keyword2&wcmfield.autosave=true
To edit a content item, automatically save the item and prevent any validation exception from being displayed, use autosave with saveValidate=false:
- Tag: [plugin:RemoteAction action="edit" doc wcmfield.content.keywords="keyword1" wcmfield.autosave="true" wcmfield.saveValidate="false"]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=edit&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1&wcmfield.content.keywords=keyword1&wcmfield.autosave=true&wcmfield.saveValidate=false
To create a content item, set the name and use autosave to automatically save the content (no dialog opens). The authoring template used by the content item must have a workflow pre-selected:
- Tag: [plugin:RemoteAction action="new" type="com.ibm.workplace.wcm.api.WCM_Content" at p wcmfield.content.name="newcontent" wcmfield.autosave="true" wcmfield.saveValidate="true"]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=new&type=com.ibm.workplace.wcm.api.WCM_Content&atid=com.ibm.workplace.wcm.api.WCM_AuthoringTemplate/ID1&pid=com.ibm.workplace.wcm.api.WCM_SiteArea/ID2&wcmfield.content.name=newcontent&wcmfield.autosave=true&wcmfield.saveValidate=true
To edit a content item and create a draft on the edit and set the history log comment:
- Tag: [plugin:RemoteAction action="edit" doc createDraft="true" comment="comment"]
- Url: http://<host>/wps/myportal/wcmAuthoring?wcmAuthoringAction=edit&docid=com.ibm.workplace.wcm.api.WCM_Content/ID1&createDraft=true&comment=comment
Parent Developing