Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2006 EMC Corporation. All rights reserved. Grokking the Paradigm Creating a Component Dennis Dawson Principal Technical Writer EMC/Documentum.

Similar presentations


Presentation on theme: "© 2006 EMC Corporation. All rights reserved. Grokking the Paradigm Creating a Component Dennis Dawson Principal Technical Writer EMC/Documentum."— Presentation transcript:

1

2 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm Creating a Component Dennis Dawson Principal Technical Writer EMC/Documentum

3 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm2 Fifteen Minutes’ Worth of Stuff Creating a Custom Component –Lay out the UI –Create Java behavior classes –Create configuration files

4 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm3 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

5 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm4 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

6 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm5 Creating a Component The UI Layer

7 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm6 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.

8 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm7 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); }

9 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm8 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 ... version_permit edit editcontainer

10 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm9 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;

11 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm10 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;

12 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm11 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;

13 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm12 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;

14 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm13 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;

15 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm14 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;

16 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm15 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";

17 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm16 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(); }

18 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm17 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; }

19 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm18 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); }

20 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm19 Creating a Component – The Java Behavior Class public void onClickSaveChanges(Control control, ArgumentList args) { saveXmlData(); }

21 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm20 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(); }

22 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm21 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(); }

23 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm22 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(); }

24 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm23 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(); }

25 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm24 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(); }

26 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm25 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(); }

27 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm26 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(); }

28 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm27 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 /custom/library/xmlViewer.jsp com.documentum.custom.library.XMLViewer

29 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm28 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

30 © 2006 EMC Corporation. All rights reserved. Grokking the Paradigm29 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

31 © 2006 EMC Corporation. All rights reserved. Clarifications/comments? Please send them to: WDK Questions? Please visit:


Download ppt "© 2006 EMC Corporation. All rights reserved. Grokking the Paradigm Creating a Component Dennis Dawson Principal Technical Writer EMC/Documentum."

Similar presentations


Ads by Google