Announcement Announcement Module
Collapse
No announcement yet.
<action-bean> vs MultiAction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <action-bean> vs MultiAction

    Is there a big difference between using action-bean versus extending MultiAction? Are there trade-offs? Are there places where one can't be used instead of the other?

  • #2
    Hi ccaning,


    I usually use MultiAction, FormAction or Action classes of Spring Web Flow if I want to manipulate something in the web application context.

    Example, if I want to have a reference of HttpServletRequest, I could easily do this,


    Code:
    public Event SampleEvent( RequestContext context )
    {
            HttpServletRequest request = ( (ServletExternalContext) context.getExternalContext() ).getRequest();
    
    ...
       return success();
    }



    or if I want to have a reference to the formObject of FormAction so that I could put values to it if ever I'm editing an object I would do this...


    Code:
        public Event setupReferenceData( RequestContext context ) throws Exception
        {
            MutableAttributeMap flashScope = context.getFlashScope();
    
            User user = (User) flashScope.get( "toBeEditedUser" );
    
            UserBean formObject = (UserBean) getFormObject( context );
    
            formObject.setUserId( user.getUserId() );
            formObject.setAccess( user.getAccess() );
            formObject.setEnabled( user.isEnabled() );
            formObject.setPassword( user.getPassword() );
            formObject.setUsername( user.getUsername() );
    
            return success();
        }


    Basically <action bean> is used for pojo classes that are responsible for the business logic of the application.

    Comment


    • #3
      Hello,

      with an bean-action you don't have any dependency on SWF APIs (or any apis in generall), you can call any POJO method.
      The trade-off there is, that you don't have access to the RequestContext, so you can't put more then one object into a particular scope with one bean call.

      rgds
      agim

      Comment


      • #4
        Thanks. I think I understand it now.

        Comment

        Working...
        X