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

Thread: <evaluate expression="" result="" />

  1. #1

    Default <evaluate expression="" result="" />

    Hi,

    Sorry, though I'm kinda frustrated trying to find good reference material on web flow...

    How exactly does evaulate expression work? I was unable to find a satisfactory detailed technical explanation on the reference guide?

    What I understood so far, is that if I return a boolean, that it can evaluate this result, and if true the flow can continue, if false the flow will not continue (transition).

    If the expression is calling a method and a method throws an exception, web flow seems to bomb out...

    What happens if I have a result that is returned from a method? How can I inform web flow not to transition in this case, since the return value is not a boolean?

    BTW, I bought the web flow book from ervacon, though its outdated and not as useful now that web flow 2.0 is out and drastically different....where can I get good docs to help me develop?

    Thanks,
    Josh

  2. #2
    Join Date
    Mar 2008
    Posts
    170

    Default

    I think you have missunderstood the meaning of evaluate.

    Just take a look at the provided documentation:

    http://static.springframework.org/sp...-reference.pdf

    Read Chapter 2.6. Actions


    - Peter

  3. #3

    Default

    Hi Peter,

    Thanks for your reply.

    Though as I mentioned, I already read through the reference guide.

    Can you be more specific as to what I may have missed?

    Here is the section in partcular which is vague for the question I asked...how do I handle booleans if I have a result?

    4.6
    4.9. Transition actions

    A view-state transition can execute one or more actions before executing. These actions may return an error result to prevent the transition itself from executing. If an error result occurs, the view will re-render and should typically display an appropriate error message to the user.

    If the transition action invokes a plain Java method, the invoked method may return false to prevent the transition from executing. This technique can be used to handle exceptions thrown by service-layer methods. The example below invokes an action that calls a service and handles an exceptional situation:

    <transition on="submit" to="bookingConfirmed">
    <evaluate expression="bookingAction.makeBooking(booking, messageContext)" />
    </transition>


    public class BookingAction {
    public boolean makeBooking(Booking booking, MessageContext context) {
    try {
    bookingService.make(booking);
    return true;
    } catch (RoomNotAvailableException e) {
    context.addMessage(builder.error().
    .defaultText("No room is available at this hotel").build());
    return false;
    }
    }
    }

  4. #4

    Default

    I also think that the reference should give more details... not just a brief description and a sample.

    They should explain all attributes and what type of value they expect... and give a description of each attribute too.

  5. #5
    Join Date
    Mar 2008
    Posts
    170

    Default

    @Josh,

    how do I handle booleans if I have a result?
    In case you are using the <evaulate> tag within a <transition> tag and the method you evaluate returns a boolean of false the transition will not occur. This is just a special feature of the evalaute tag in case you use it in the mentioned context (within a transition tag).
    In general the evaluate tag allows you to execute a method on a bean and gives you the possibility to save the result via result="" attribute, e.g.:

    Code:
    <evaluate expression="foo.bar()" result="flowScope.resultVarName">
    So the result of the method bar will be saved under the name resultVarName.

    Does this answer you questions?
    Have you taken a look at the sample projects?

    @Guilherme ,

    I also think that the reference should give more details... not just a brief description and a sample.

    They should explain all attributes and what type of value they expect... and give a description of each attribute too.
    I think the term should is not appropriate. The SpringTeam could mention that you should read the reference documentation, that you should study the sample applications, that you should browse the forum that......
    Imho we get here some really cool stuff for free and my way to appreciate that is to read this forum regulary and try to answer some questions (I'm also "new" to SWF).

    - Peter

  6. #6

    Default

    Peter,

    I'm sorry. From my post looks like I don't appreciate the great work that th SpringTeam do. But I do appreciate very much.

    Also I appreciate your help too... you already helped me a lot (by anwser my posts or other people's)

    On the post I was trying to do a more like suggestion, not a hard critic. And looking again I think I didn't express myself the way I should. But I'm not an english speaker and sometimes I have this problems.

    About the reference documentation, there are parts that are just great, like the MVC, JSF and RichFaces integration. The forum also helps a lot but I can't find all I need...

    If you can please give me some indication about a good book on SWF2.0 I would appreciate that.

    Regards,

    Guilherme

  7. #7
    Join Date
    Mar 2008
    Posts
    170

    Default

    Guilherme,



    I guess SWF 2.0 is not available long enough for a book about it.

    I can strongly recommend to study the sample applications in combination with the available documentation.
    If you have afterwards questions I'm pretty sure that somebody in this forum can answer them (at least I will try )

    - Peter

  8. #8

    Default

    Code:
    <evaluate expression="foo.bar()" result="flowScope.resultVarName">

    What I'm trying to do, is in the above example, if foo.bar does not return a boolean, let's say a list of Strings, if the method throws an exception, how do I inform the transition not to continue?

    If foo.bar returned a boolean rather than a list of strings, then I could catch the exception in foo.bar and return false, though since it returns a list of strings, I can't do that...

    In SWF 2.0, I'm trying to figure out how to do a decision state and then transition.

    Thanks,
    Josh

  9. #9
    Join Date
    Mar 2008
    Posts
    170

    Default

    Perhaps you can use the on-exception attribute in the transition tag.

    See http://forum.springframework.org/sho...t=on-exception

    - Peter

  10. #10

    Default

    Ok, cool...that will get me going for now.

    Is there some spring web flow wiki, would be nice to add this info as I'm unable to find it in the reference guide.

Tags for this Thread

Posting Permissions

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