Portlet Development III - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Portlet Development III

Description:

Portals & Portlets 2003; July 14 -17 2003; Edinburgh ... Future goal is to integrate JavaScript/DHTML into tags for increased interactivity ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 15
Provided by: nes5
Category:

less

Transcript and Presenter's Notes

Title: Portlet Development III


1
Portlet Development III
The ActionPortlet Model Tags, Beans, and Events
Jason Novotny novotny_at_aei.mpg.de Michael Russell
russell_at_aei.mpg.de Oliver Wehrens
wehrens_at_aei.mpg.de

Albert Einstein Institute
2
Critique of Portlet Model
  • In complex portlet development navigation between
    various views and events can be difficult to
    manage
  • Developers must still write lots of tedious
    CSS/HTML to create presentations.
  • Lots of portlet actions can lead to
    actionPerformed methods with large amounts of
    branching logic

public void actionPerformed(ActionEvent event)
String actionName event.getAction().getName()
if (actionName.equals(doThis)
doThis() else if (actionName.equals(doTha
t)) doThat() else if
3
The ActionPortlet
  • ActionPortlet acts as an intelligent dispatcher
    that hides branching logic from a portlet
    developer
  • A subclass of ActionPortlet makes use of the
    dispatching mechanisms and defines the action and
    view methods to invoke for a particuar event
  • ActionPortlet provides setNextState() method that
    is used to specify the next display state that
    should be presented after an action method. Also
    setNextTitle and setNextError are provided.
  • ActionPortlet provides default actionPerformed
    and doXXX methods so normally these methods need
    not be defined in the ActionPortlet subclass
  • Specify default pages in init method of portlet
    DEFAULT_VIEW_PAGE, DEFAULT_EDIT_PAGE, etc.

4
Example Portlet
public class ExamplePortlet extends ActionPortlet
public void init(PortletConfig config)
throws UnavailableException
super.init(config) public void
initConcrete(PortletSettings settings) throws
UnavailableException super.initConcrete(
settings) DEFAULT_VIEW_PAGE
example/view.jsp" public void
doStuff(FormEvent event) throws PortletException
setNextState(event.getPortletRequest()
, DEFAULT_VIEW_PAGE)
5
Action Methods
  • ActionPortlet provides subclassed portlets with
    FormEvent object that acts as decorator for
    ActionEvent to provide form-based visual
    components

public interface FormEvent extends ActionEvent
public FileInputBean getFileInputBean(String
beanId) throws IOException public
ErrorFrameBean getErrorFrameBean(String beanId)
public CheckBoxBean getCheckBoxBean(String
beanId) public TextFieldBean
getTextFieldBean(String beanId) public
HiddenFieldBean getHiddenFieldBean(String
beanId) public PasswordBean
getPasswordBean(String beanId) public
TextAreaBean getTextAreaBean(String beanId)
public TextBean getTextBean(String beanId)
6
Visual Beans
  • Instead of using HTML in Portlet java code,
    visual beans provide wrappers around CSS/HTML
    that allows portlet developers to modify or
    create presentation elements
  • Standard HTML elements are wrapped as beans
  • CheckBoxBean. ListBoxBean, TableBean,
    HiddenFieldBean, TextFieldBean, PasswordBean.
    etc.
  • Beans are identified by tags, called beanId
    which acts a label.
  • Beans are created at every request and are
    updated after request has been generated and made
    available to portlet action methods
  • Every visual bean has a corresponding UI tag that
    may be used in JSP pages to produce presentation
    output

7
UI Tag Library
  • Action model provides value-added tag library to
    make creating presentations more like component
    based design like Swing.
  • Tags that wish to be accessed by a portlet must
    declare a beanId

ltuiformgt ltuipanelgt ltuiframegt
ltuitablerowgt ltuitablecell
width"100"gt ltuitext
key"LOGIN_NAME"/gt
lt/uitablecellgt lt/uitablerowgt
lt/uiframegt lt/uipanelgt lt/uiformgt
8
UI Tag Usage
  • Any JSP that wishes to use the UI tag library
    must include the following boilerplate JSP
  • This instructs the page to include the Portlet
    and UI tag libraries

lt_at_ taglib uri"/portletUI" prefix"ui" gt lt_at_
taglib uri"/portletAPI" prefix"portletAPI"
gt ltportletAPIinit/gt
9
UI Tag Attributes
  • Most presentation beans/tags subclass from
    BaseComponentBean and BaseComponentTag which
    provides following fields
  • beanId - name of the presentation tag/bean
  • name - name as used in HTML elements
  • value - value as used in HTML elements
  • key - a key that represents a localized
    properties file key
  • width - width of the component
  • font - font to be used
  • cssStyle - the CSS style
  • Tag attributes can also be passed in as request
    time values
  • ltuitext valuelt myFavoriteFruit gt/gt

10
Localized Messages
  • In general any text displayed in a portlet should
    be localized
  • Use the TextTag!
  • ltuitext key"LOGIN"/gt
  • The key attribute specifies the key used in the
    Portlet.properties_ltcountrygt file found in
    WEB-INF/classes
  • All presentation tags that display text include
    key attribute
  • ActionSubmitTag for displaying buttons

11
Creating Actions
  • Action presentation elements can trigger portlet
    events
  • ActionLink -- creates a hyperlink with a
    specified action
  • ActionSubmitButton -- creates a button with a
    specified action
  • Form-- provides action attribute to trigger an
    action from a form submission
  • Action elements can include nested ActionParam
    elements for associating additional name/value
    parameters to an action

12
Creating Actions (cont.)
  • Creating an actionlink with actionparams
  • ltuiactionlink actiondoSomething" valueClick
    Me"gt
  • ltuiactionparam namecolor valuered/gt
  • ltuiactionparam namefruit valueapple/gt
  • lt/uiactionlinkgt
  • Creating a default form
  • ltuiform actiondoActiongt
  • ltuitextfield beanIdfruit size15
    valueapple/gt
  • lt/uiformgt
  • Creating a form with buttons
  • ltuiformgt
  • ltuiactionsubmit actiondoAction valueClick
    Me/gt
  • ltuiactionsubmit actiondoAnotherAction
    valueNo, me/gt
  • lt/uiformgt

13
Container Tags and Beans
  • Several beans/tags act as containers for other
    beans/tags
  • A ltuipanelgt tag contains nested ltuiframegt or
    ltuitablegt tags to produce stylized nested tables
  • A ltuitablegt or ltuiframegt tag is composed of
    nested ltuitablerowgt tags which contain nested
    ltuitablecellgt tags to produce stylized tables
  • A ltuiformgt tag is a container for all tags
    included within it.
  • A ltuilistboxgt tag can contain nested
    ltuilistboxitemgt tags
  • Action tags are containers for ltuiactionparamgt
    tags to specify additional action parameters.

14
Conclusion
  • ActionPortlet model is the GridSphere
    recommended approach for building complex
    portlets
  • Tags and Beans provide value-added functionality
  • Default navigation methods take care of
    forwarding to the appropriate page, error
    handling and setting portlet title.
  • The UI tag library provides a toolbox of reusable
    presentation components
  • UI tag library frees developers from working with
    HTML/CSS
  • Future goal is to integrate JavaScript/DHTML into
    tags for increased interactivity
  • Please contact us with comments, questions,
    suggestions on improving the model!
Write a Comment
User Comments (0)
About PowerShow.com