Announcement Announcement Module
Collapse
No announcement yet.
Changing eventId(s) per view-state with same view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing eventId(s) per view-state with same view

    Is there a way to have different eventId(s) with different view states, but with the same view?

    For example:

    View
    Code:
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <form:form modelAttribute="daForm">
      <c:if test="view-state1">
        <input type="submit" id="next" name="_eventId_next" value="NEXT" />
      </c:if>
      <c:if test="view-state2">
        <input type="submit" id="save" name="_eventId_save" value="SAVE" />
        <input type="submit" id="cancel" name="_eventId_cancel" value="CANCEL" />" />
      </c:if>
    </form:form>
    What goes into view-state1 and view-state2?

    Flow.xml
    Code:
    <view-state id="view-state1" view="view" model="someModel">
      <transition on="next" to="view-state2" />
    </view-state>
    
    <view-state id="view-state2" view="view" model="someModel">
      <transition on="save" to="save" />
      <transition on="cancel" to="cancel" bind="false" />
    </view-state>
    
    <end-state id="save" />
    <end-state id="cancel" />
    Could somebody please help me with this issue?
    Thanks
    Alex

  • #2
    You may be able to do something like this:

    Code:
    <c:if test="${flowRequestContext.currentState.id == 'view-state1'}">
    ...
    See the API for the RequestContext interface for the methods available to you.


    Alternatively, to add more context and meaning to your test or variable, you can always add a view-scoped attribute to each view-state, each with a different value. I typically use all caps for flags or view-scoped constants like these.

    A very basic example (similar to what you're trying now) would be:

    Code:
    <view-state id="view-state1" view="view" model="someModel">
       <set name="LAST_STEP" value="false"/>
    ...
    
    <view-state id="view-state2" view="view" model="someModel">
       <set name="LAST_STEP" value="true"/>
    ...
    Then either have your conditionals in your JSP on LAST_STEP or not LAST_STEP, or use a choose/when/otherwise construct.

    Comment

    Working...
    X