1 / 30

Grokking the Paradigm Creating a Component

Grokking the Paradigm Creating a Component. Dennis Dawson Principal Technical Writer EMC/Documentum. Creating a Custom Component Lay out the UI Create Java behavior classes Create configuration files. Fifteen Minutes’ Worth of Stuff. Creating a Component. Components are composed of

Download Presentation

Grokking the Paradigm Creating a Component

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grokking the ParadigmCreating a Component Dennis Dawson Principal Technical Writer EMC/Documentum

  2. Creating a Custom Component Lay out the UI Create Java behavior classes Create configuration files Fifteen Minutes’ Worth of Stuff Grokking the Paradigm

  3. Creating a Component • Components are composed of • The UI Layer (JSP) • Behavior (Java) • Configuration (XML) • For this example, we’ll create a simple XML editor • We’ll create a new UI, a component configuration and supporting Java class • We’ll extend the existing edit_file action configuration and extend its supporting Java class Grokking the Paradigm

  4. No Rules!! • You can create the parts in any order • I like to start with the UI • Show it to your users for feedback before you complete the implementation • Something tangible to look at as you develop the component • Feel like you’ve accomplished something Grokking the Paradigm

  5. Creating a ComponentThe UI Layer <%@ page contentType = "text/html" %> <%@ page errorPage = "/wdk/errorhandler.jsp" %> <%@ taglib uri = "/WEB-INF/tlds/dmform_1_0.tld" prefix="dmf" %> <dmf:html><dmf:head> <dmf:webform /> </dmf:head><dmf:body><dmf:form> <dmf:table><dmf:tr><dmf:td colspan = "2" > <dmf:textarea name = "textXmlData" rows = "30" cols = "150" /> </dmf:td></dmf:tr><dmf:tr><dmf:td> <dmf:button name = "save" label = "Save Changes" onclick = "onClickSaveChanges" /> </dmf:td><dmf:td align = "right" > <dmf:button name = "cancel" label = "Cancel Changes“ onclick = "onClickCancel" /> </dmf:td></dmf:tr></dmf:table> </dmf:form></dmf:body></dmf:html> Grokking the Paradigm

  6. Creating a Component – The UI JSP • The UI consists of a text area for editing, a button to save changes, and a button to cancel changes. Grokking the Paradigm

  7. Creating a Component –Java Behavior Class • LaunchXMLViewer extends LaunchComponentWithPermitCheck • Here’s the interesting chunk of code public boolean execute( String strAction,IConfigElement config, ArgumentList args, Context context, Component component, java.util.Map map) { ... if((strContentType.indexOf(m_strXMLContentType) == -1) && (strContentType.indexOf(m_strXSLContentType) == -1)) { return (super.execute( strAction, config,args,context,component,map) ); } else { component.setComponentNested( "xmlviewer",args,component.getContext(),null); } Grokking the Paradigm

  8. Creating a Component -Configuring the Action • We need to extend dm_sysobject_actions.xml • We’ll modify the editfile action to point to our new Java class <?xml ... <action id = "editfile“ extends= "editfile:/webcomponent/config/actions/dm_sysobject_actions.xml" > ... <execution class = "com.documentum.custom.action.LaunchXMLViewer" > <permit>version_permit</permit> <component>edit</component> <container>editcontainer</container> </execution> </action> Grokking the Paradigm

  9. Creating a Component – The Java Behavior Class • Let’s pick the XMLViewer class apart a section at a time, starting with the import statements package com.documentum.custom.library; import com.documentum.web.common.ArgumentList; import com.documentum.web.form.Control; import com.documentum.web.form.control.TextArea; import com.documentum.web.formext.component.Component; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfId; import com.documentum.fc.common.DfException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; Grokking the Paradigm

  10. Creating a Component – The Java Behavior Class • Let’s pick the behavior class apart a section at a time, starting with the import statements package com.documentum.custom.library; import com.documentum.web.common.ArgumentList; import com.documentum.web.form.Control; import com.documentum.web.form.control.TextArea; import com.documentum.web.formext.component.Component; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfId; import com.documentum.fc.common.DfException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; Grokking the Paradigm

  11. Creating a Component – The Java Behavior Class • Let’s pick the behavior class apart a section at a time, starting with the import statements package com.documentum.custom.library; import com.documentum.web.common.ArgumentList; import com.documentum.web.form.Control; import com.documentum.web.form.control.TextArea; import com.documentum.web.formext.component.Component; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfId; import com.documentum.fc.common.DfException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; Grokking the Paradigm

  12. Creating a Component – The Java Behavior Class • Let’s pick the behavior class apart a section at a time, starting with the import statements package com.documentum.custom.library; import com.documentum.web.common.ArgumentList; import com.documentum.web.form.Control; import com.documentum.web.form.control.TextArea; import com.documentum.web.formext.component.Component; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfId; import com.documentum.fc.common.DfException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; Grokking the Paradigm

  13. Creating a Component – The Java Behavior Class • Let’s pick the behavior class apart a section at a time, starting with the import statements package com.documentum.custom.library; import com.documentum.web.common.ArgumentList; import com.documentum.web.form.Control; import com.documentum.web.form.control.TextArea; import com.documentum.web.formext.component.Component; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfId; import com.documentum.fc.common.DfException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; Grokking the Paradigm

  14. Creating a Component – The Java Behavior Class • Let’s pick the behavior class apart a section at a time, starting with the import statements package com.documentum.custom.library; import com.documentum.web.common.ArgumentList; import com.documentum.web.form.Control; import com.documentum.web.form.control.TextArea; import com.documentum.web.formext.component.Component; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSysObject; import com.documentum.fc.common.DfId; import com.documentum.fc.common.DfException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; Grokking the Paradigm

  15. Creating a Component – The Java Behavior Class • In my examples, I put my variable definitions at the top of the file for readability, but they usually show up at the end of most Java files. public class XMLViewer extends Component { private String m_strObjectId = null; private IDfSysObject m_sysObjectXmlDoc = null; private String m_strXmlData = null; private IDfSession m_docbaseSession = null; private static final String m_strXMLContentType = "xml"; Grokking the Paradigm

  16. Creating a Component – The Java Behavior Class • The initialization routine initializes the XML content, and, if successful, displays it in the text area public void onInit(ArgumentList args) { super.onInit(args); m_strObjectId = args.get("objectId"); if(m_strObjectId != null) { m_docbaseSession = getDfSession() if(initXMLContent()) { displayXmlData(); } } } Grokking the Paradigm

  17. Creating a Component – The Java Behavior Class This method reads the XML content into the m_strXmlData variable: private boolean initXMLContent() {... String contentType = m_sysObjectXmlDoc.getContentType(); if( m_sysObjectXmlDoc.isCheckedOut()) { String lockOwner = m_sysObjectXmlDoc.getLockOwner(); String currentUser = getCurrentLoginUsername(); if(! currentUser.equals(lockOwner)) return false; } ByteArrayInputStream xmlData = m_sysObjectXmlDoc.getContent(); byte byteXmlData[] = new byte[xmlData.available() + 3]; xmlData.read(byteXmlData,0,xmlData.available()); m_strXmlData = new String(byteXmlData); return true; } Grokking the Paradigm

  18. Creating a Component – The Java Behavior Class The second piece to instantiation is actually displaying the XML data private void displayXmlData() { TextArea textArea = (TextArea) getControl("textXmlData"); if(textArea == null) { textArea = (TextArea) createControl("textXmlData",TextArea.class); } textArea.setValue(m_strXmlData); } Grokking the Paradigm

  19. Creating a Component – The Java Behavior Class public void onClickSaveChanges(Control control, ArgumentList args) { saveXmlData(); } } Grokking the Paradigm

  20. Creating a Component – The Java Behavior Class private void saveXmlData() { if(m_sysObjectXmlDoc.isCheckedOut()) { TextArea textArea = (TextArea) getControl("textXmlData"); m_strXmlData = textArea.getValue(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(m_strXmlData.getBytes()); m_sysObjectXmlDoc.setContent(outputStream); m_sysObjectXmlDoc.checkin(false,""); setComponentReturn(); } else { setComponentReturn(); } } Grokking the Paradigm

  21. Creating a Component – The Java Behavior Class private void saveXmlData() { if(m_sysObjectXmlDoc.isCheckedOut()) { TextArea textArea = (TextArea) getControl("textXmlData"); m_strXmlData = textArea.getValue(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(m_strXmlData.getBytes()); m_sysObjectXmlDoc.setContent(outputStream); m_sysObjectXmlDoc.checkin(false,""); setComponentReturn(); } else { setComponentReturn(); } } Grokking the Paradigm

  22. Creating a Component – The Java Behavior Class private void saveXmlData() { if(m_sysObjectXmlDoc.isCheckedOut()) { TextArea textArea = (TextArea) getControl("textXmlData"); m_strXmlData = textArea.getValue(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(m_strXmlData.getBytes()); m_sysObjectXmlDoc.setContent(outputStream); m_sysObjectXmlDoc.checkin(false,""); setComponentReturn(); } else { setComponentReturn(); } } Grokking the Paradigm

  23. Creating a Component – The Java Behavior Class private void saveXmlData() { if(m_sysObjectXmlDoc.isCheckedOut()) { TextArea textArea = (TextArea) getControl("textXmlData"); m_strXmlData = textArea.getValue(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(m_strXmlData.getBytes()); m_sysObjectXmlDoc.setContent(outputStream); m_sysObjectXmlDoc.checkin(false,""); setComponentReturn(); } else { setComponentReturn(); } } Grokking the Paradigm

  24. Creating a Component – The Java Behavior Class private void saveXmlData() { if(m_sysObjectXmlDoc.isCheckedOut()) { TextArea textArea = (TextArea) getControl("textXmlData"); m_strXmlData = textArea.getValue(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(m_strXmlData.getBytes()); m_sysObjectXmlDoc.setContent(outputStream); m_sysObjectXmlDoc.checkin(false,""); setComponentReturn(); } else { setComponentReturn(); } } Grokking the Paradigm

  25. Creating a Component – The Java Behavior Class private void saveXmlData() { if(m_sysObjectXmlDoc.isCheckedOut()) { TextArea textArea = (TextArea) getControl("textXmlData"); m_strXmlData = textArea.getValue(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(m_strXmlData.getBytes()); m_sysObjectXmlDoc.setContent(outputStream); m_sysObjectXmlDoc.checkin(false,""); setComponentReturn(); } else { setComponentReturn(); } } Grokking the Paradigm

  26. Creating a Component – The Java Behavior Class public void onClickCancel(Control control, ArgumentList args) { try { if(m_sysObjectXmlDoc.isCheckedOut()) { m_sysObjectXmlDoc.cancelCheckout(); } } catch(DfException dfe) { dfe.printStackTrace(); } setComponentReturn(); } Grokking the Paradigm

  27. Creating a Component – The Component Configuration File • We create a component definition in an XML configuration file. • This is the “glue” that associates the UI with the Java behavior class <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <config version="1.0"> <scope type = "dm_document" > <component id = "xmlviewer" > <params> <param name = "objectId" required = "true" /> </params> <pages> <start>/custom/library/xmlViewer.jsp</start> </pages> <class>com.documentum.custom.library.XMLViewer</class> </component> </scope> </config> Grokking the Paradigm

  28. Creating a Component – Deploying the Component • After creating all of these files and compiling the Java classes, you deploy the files to the following locations: /webtop/custom/library/xmlViewer.jsp /webtop/custom/config/edit_action.xml /webtop/custom/config/xmlviewer_component.xml /webtop/WEB-INF/classes/com/documentum/custom/action/ LaunchXMLViewer.class /webtop/WEB-INF/classes/com/documentum/custom/library/ XMLViewer.class Grokking the Paradigm

  29. Multiplicitas Componatis Res Simplex • Taken as a whole, Webtop and WDK-based applications are intricate, multifaceted feats of programming • When you focus on any one element of the application, it’s easy to follow the logic and duplicate its behavior • Once you grok the paradigm, enhancing and customizing complex applications becomes a series of simple steps Grokking the Paradigm

  30. Clarifications/comments?Please send them to:dawson_dennis@emc.comWDK Questions? Please visit:http://developer.emc.com/developer/

More Related