Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Dynamic ElementsJohann WernerNUREG GmbH
Outline•   What are components•   Different common types•   Dynamic components
Components•   reusable pieces of representation + functionality•   WebObjects comes with many    (e.g. WOBody, WORepetitio...
Components      Component API      Code      Template      Binding declarations      Info file
Standard Component•   subclass of WOComponent•   automatic push/pull of binding values•   preserves state
Standard ComponentParent                                Code                                          Template[…]         ...
Non-Synchronizing Component•   manual push/pull of binding values➡ less overhead•   preserves state
Non-Synchronizing ComponentParent                                Code                                                     ...
Non-Synchronizing ComponentParent                                Code                                                     ...
Stateless Component•   manual push/pull of binding values➡ less overhead•   no state•   single shared instance*➡ less memo...
Stateless ComponentParent                                Code                                          Template[…]        ...
Stateless ComponentParent                                Code                                          Template[…]        ...
Dynamic Component•   subclass of WODynamicElement•   no template➡ less memory, faster•   direct access to bindings (WOAsso...
Dynamic ComponentParent                                Code[…]                                   public class MyString ext...
Demo
Demo Results•   The more specialized component class the faster it is•   Stateless and dynamic components create less Java...
When should I use…Standard components•   for pages, big blocksNon Synchronizing components•   smaller components that are ...
When should I use…Stateless components •   no state necessary •   memory optimizationDynamic components •   no state neces...
Component Class Tree                                        Object                                    WOElement           ...
Component Class Tree                                        Object                                    WOElement           ...
Component Class Tree                                                              Object                ERXLoremIpsum,    ...
Component Class Tree                                         Object                                    WOElement          ...
Dynamic Base Classes•   ERXDynamicElement in ERXExtensions•   AjaxDynamicElement in Ajax
DEMO
Creating Dynamic Element•   extend ERXDynamicElement / AjaxDynamicElement•   appendToResponse    •   response.appendConten...
Creating Dynamic Element•   xxxValueForBinding(name, [default,] component)•   ContextData    •   beforeProcessing(context)...
MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Q&A
Upcoming SlideShare
Loading in …5
×

Dynamic Elements

999 views

Published on

Learn how you can create your own dynamic elements to use in your WebObjects components.

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

Dynamic Elements

  1. 1. MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Dynamic ElementsJohann WernerNUREG GmbH
  2. 2. Outline• What are components• Different common types• Dynamic components
  3. 3. Components• reusable pieces of representation + functionality• WebObjects comes with many (e.g. WOBody, WORepetition, WOString, …)• Wonder adds a whole bunch (e.g. AjaxModalContainer, ERXLocalizedString, …)
  4. 4. Components Component API Code Template Binding declarations Info file
  5. 5. Standard Component• subclass of WOComponent• automatic push/pull of binding values• preserves state
  6. 6. Standard ComponentParent Code Template[…] public class MyString extends WOComponent { <wo:str value="$value" /><wo:MyString value="Hello World" /> public String value;[…] public MyString(WOContext context) { super(context); } }
  7. 7. Non-Synchronizing Component• manual push/pull of binding values➡ less overhead• preserves state
  8. 8. Non-Synchronizing ComponentParent Code Template[…] public class MyString extends WOComponent { <wo:str value="$value" /><wo:MyString value="Hello World" /> public MyString(WOContext context) {[…] super(context); } @Override public boolean synchronizesVariablesWithBindings() { return false; } public String value() { return (String) valueForBinding("value"); } }
  9. 9. Non-Synchronizing ComponentParent Code Template[…] public class MyString extends WOComponent { <wo:str value="$^value" /><wo:MyString value="Hello World" /> public MyString(WOContext context) {[…] super(context); } @Override public boolean synchronizesVariablesWithBindings() { return false; } }
  10. 10. Stateless Component• manual push/pull of binding values➡ less overhead• no state• single shared instance*➡ less memory, fewer Java object-creations
  11. 11. Stateless ComponentParent Code Template[…] public class MyString extends WOComponent { <wo:str value="$^value" /><wo:MyString value="Hello World" /> public MyString(WOContext context) {[…] super(context); } @Override public boolean isStateless() { return true; } }
  12. 12. Stateless ComponentParent Code Template[…] public class MyString extends WOComponent { <wo:str value="$^value" /><wo:MyString value="Hello World" /> private Object myVar;[…] public MyString(WOContext context) { super(context); } @Override public boolean isStateless() { return false; } @Override public void reset() { super.reset(); myVar = null; } }
  13. 13. Dynamic Component• subclass of WODynamicElement• no template➡ less memory, faster• direct access to bindings (WOAssociation)• direct access to children elements• must be thread-safe!
  14. 14. Dynamic ComponentParent Code[…] public class MyString extends WODynamicElement {<wo:MyString value="Hello World" /> private WOAssociation value;[…] public MyString(String name, NSDictionary<String, WOAssociation> associations, WOElement template) { super(name, associations, template); value = associations.get("value"); } @Override public void appendToResponse(WOResponse response, WOContext context) { WOComponent component = context.component(); response.appendContentString((String) value.valueInComponent(component)); } }
  15. 15. Demo
  16. 16. Demo Results• The more specialized component class the faster it is• Stateless and dynamic components create less Java objects
  17. 17. When should I use…Standard components• for pages, big blocksNon Synchronizing components• smaller components that are used often• binding has • different name as the variable to hold it • no variable counterpart
  18. 18. When should I use…Stateless components • no state necessary • memory optimizationDynamic components • no state necessary • complex output generation • access to child elements
  19. 19. Component Class Tree Object WOElement WODynamicElement WOHTMLBareString WOComponent WODynamicGroup AjaxComponent D2WComponent ERXComponent JSComponent WOHTMLDynamic- D2WStateless- ERXNonSynchronizing-AjaxDynamicElement Element Component Component WOHTMLURLValued- ERXStateless- WOInput Element Component
  20. 20. Component Class Tree Object WOElement WODynamicElement WOHTMLBareString WOComponent WODynamicGroup AjaxComponent D2WComponent ERXComponent JSComponent WOHTMLDynamic- D2WStateless- ERXNonSynchronizing-AjaxDynamicElement Element Component Component WOHTMLURLValued- ERXStateless- WOInput Element Component
  21. 21. Component Class Tree Object ERXLoremIpsum, ERXWOSwitch, … WOElement AjaxHighlight, ERXWORepetition, … WODynamicElement WOHTMLBareString WOComponentAjaxHyperlink, AjaxFunctionLink,AjaxSubmitButton, … ERXJavaScript, … WODynamicGroup AjaxComponent D2WComponent ERXComponent JSComponent WOBody, WOHTMLDynamic- WOFrame, … D2WStateless- ERXNonSynchronizing- AjaxDynamicElement Element Component Component ERXSubmitButton, WOHTMLURLValued- WOInput WOCheckBox, ERXStateless- … Element Component
  22. 22. Component Class Tree Object WOElement WODynamicElement WOHTMLBareString WOComponent WODynamicGroup AjaxComponent D2WComponent ERXComponent JSComponent WOHTMLDynamic- D2WStateless- ERXNonSynchronizing-ERXDynamicElement Element Component Component WOHTMLURLValued- ERXStateless-AjaxDynamicElement WOInput Element Component
  23. 23. Dynamic Base Classes• ERXDynamicElement in ERXExtensions• AjaxDynamicElement in Ajax
  24. 24. DEMO
  25. 25. Creating Dynamic Element• extend ERXDynamicElement / AjaxDynamicElement• appendToResponse • response.appendContentString(…) • appendTagAttributeToResponse(response, name, value) • appendChildrenToResponse(response, context)
  26. 26. Creating Dynamic Element• xxxValueForBinding(name, [default,] component)• ContextData • beforeProcessing(context) • afterProcessing(context)
  27. 27. MONTREAL JUNE 30, JULY 1ST AND 2ND 2012Q&A

×