Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Attribute mappers question

  1. #1
    Join Date
    Jun 2005
    Posts
    6

    Default Attribute mappers question

    Sorry if I'm asking dumb question, but why attribute mappers are available only in subflows? I mean, it seams that it will be nice to have this possibility in regular flows also as they can be much more independent of each others. If you extend this further, attribute mapper for individual actions will also be nice. This way you practically came up with chain of responsibility implementation with declarative attribute mapping. It seams that this can be quite useful and not only in web context, don't you think?

    Tnx

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    That's exactly why the attribute mapping heavy lifting is part of the spring data binding project, not SWF. SWF has the notion of a FlowAttributeMapper which maps data from a parent flow to a subflow and back from a subflow state, which delegates to the binding foundational infrastructure.

    See AttributeMapperAction in the "action" subpackage, it also uses the facility and is invokable as a standard SWF action.

    Keith
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Jun 2005
    Posts
    6

    Default

    Tnx, I manage to achieve what I want with AttributeMapperAction class.

    But still, this way every single mapping must be declared with new bean configuration. It seams to me that direct support with i.e. <action-attribute-mapper> tag with list of sources and targets can be quite handy.

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    I agree. Could you create a JIRA issue?

    Keith
    Keith Donald
    Core Spring Development Team

  5. #5

    Default

    I was kindly asked by online acquaintance of mine (dcomm) to create JIRA issue about this, so here it is.

    Btw, I'm glad to see that SWF every day becoming much more usable not just for web, but in all contexts. In that respect, I can think of another small improvement that can be done. Currently in end state view identifier must be defined or NPE will be thrown. I suppose this is ok for web, but not in other context where view is not required. Is it possible to correct this also?

    Damir Murat

  6. #6
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Could you post a stack trace of that NPE? When is it occuring?
    The 'view' attribute in an end state (or even a view state) are intented to be optional!

    Erwin

  7. #7

    Default

    Actually, NPE is in my code, not in SWF. I experiment whit this before some time and remember it wrong. I apologies for that, I really should look at it more closely before posting :oops:

    Nevertheless, problem still exists. I encounter it when view id in end state is not set. In that situation FlowExecution.start(Event) method returns null and I was not able to retrieve model from it which results in NPE (in my code). Everything works fine if I set view attribute of end state to any value (i.e "dummy"). Here is a sample code.

    Code:
    public class FlowTester &#123;
      public static void main&#40;final String&#91;&#93; p_args&#41; &#123;
        ApplicationContext context =
          new ClassPathXmlApplicationContext&#40;"swftesting/applicationConfig.xml"&#41;;
    
        Flow flow = &#40;Flow&#41;context.getBean&#40;"sampleFlow"&#41;;
        FlowExecution flowExecution = new FlowExecutionImpl&#40;flow&#41;;
        Map eventParams = new HashMap&#40;&#41;;
        eventParams.put&#40;"FlowInput&#58;paramOne", "FlowInput&#58;paramOne - flow input"&#41;;
        Event startEvent = new Event&#40;new Object&#40;&#41;, "startEvent", eventParams&#41;;
    
        ViewDescriptor viewDescriptor = flowExecution.start&#40;startEvent&#41;;
        Map model = viewDescriptor.getModel&#40;&#41;;
    
        System.out.println&#40;"In FlowTester"&#41;;
        System.out.println&#40;"  " + model.get&#40;"SampleActionOne&#58;myParamOne"&#41;&#41;;
      &#125;
    &#125;
    With some further investigation, I noted that in EndState class view descriptor is set to null if EndState.isMarker() method returns true. When I chage it to "viewDescriptor = new ViewDescriptor(null, context.getModel());"
    everything works fine. At first look it seams to me that model should be exposed via ViewDescriptor even if view id is not set in end state. Am I wrong?

    Damir Murat

  8. #8
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    The idea is that you only have a 'marker' (with no view name) view state or end state if somebody else already wrote a response, e.g. an action that pulled PDF data from the DB and wrote it directly to the response. In that case there is no use in returning a model since nobody will use it: there is no view to render the model data.

    So what you see is bascically intended bahaviour. Compare it with a Spring MVC controller returning null from handleRequest().

    Erwin

  9. #9

    Default

    Thank you for clarification, I understand now why you return null .

    But on some other threads I noticed that you mentioned as SWF is not web specific (with which I highly agree). In that respect assumption that somebody else already wrote response sounds very web specific to me. If one assume some non web uses for SWF, that that model is really expected to be returned from start() method. It seams to me as really small compromise to potential non web specific users, of course if that compromise does not break something else. If this is the case, could you still consider to returning non null ViewDescriptor?

    Damir

  10. #10
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Note that SWF is web specific, that's why it's called Spring Web Flow. SWF is just not specific to any particular web technology: it integrates with things like Portlets also.

    In a 'non web environment', you could consider plugging in a custom view state and end state that change the behaviour with respect to returning null view descriptors, e.g.:

    <view-state id='...' class='my.custom.ViewState'>

    Erwin

Similar Threads

  1. Forgot password (e.g. secret question) using Acegi
    By lowerymb77 in forum Security
    Replies: 1
    Last Post: Oct 16th, 2005, 10:46 PM
  2. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM
  3. stale Oracle processes
    By compostellas in forum Data
    Replies: 7
    Last Post: Jun 27th, 2005, 12:14 PM
  4. MBeanClientInterceptor assumes lower-case Attribute names
    By Joris Kuipers in forum Container
    Replies: 10
    Last Post: Mar 31st, 2005, 09:18 AM
  5. Replies: 2
    Last Post: Sep 5th, 2004, 10:49 AM

Posting Permissions

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