Results 1 to 4 of 4

Thread: <action-bean> vs MultiAction

  1. #1
    Join Date
    Jul 2007
    Posts
    101

    Default <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. #2

    Default

    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.

  3. #3
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    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

  4. #4
    Join Date
    Jul 2007
    Posts
    101

    Default

    Thanks. I think I understand it now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •