开发者

In Spring Web Flow, how do I add # to the end of the flowExecutionKey to redirect to an anchor in a page?

Basically I want to add a # to the end of the flow execution key

e.g. _flowExecutionKey=_c8CEAE6.....E1095#

so that when the page displays it will display at the anchor tag

I have a page which is built dynamically by the user.

The user can choose to add additional fields to the page to enter more data.

The fields are an object which is stored in a list.

The page loops over all objects in the list and displays them.

I have configured an action flow that adds another object to the list and then displays the page again which causes the new fields to app开发者_开发问答ear.

The problem is that when the page loads again it is always at the top and not where the new field was added. I can add an anchor to where the new fields are generated but I don't know if its possible to add a # to the end of the flow execution key


A bit of a longshot, but I think the solution for this is probably through a combination of steps, and not so much through spring web-flow mechanisms

  • set the index of the last object edited in viewScope
  • in your jsp's, put the local anchors, say object0 to object20
  • have a bit of javascript, that 'onload' changes the location to the right anchor:

    body onload="location.href = location.href + '#object8'"

This would take you to the 8th element, without hitting the server again.


If you use forms, there is a better solution than working with javascript.

You can use anchors like this:

<form action="${flowExecutionUrl}#position" method="POST" commandName="yourForm">

In combination with setting an attribute in the workflow:

    <transition on="save" to="yourViewState" >
        <set name="flowScope.isSaved" value="true" />
    </transition>

On top in your jsp:

<c:if test="${isSaved}">
    <a id="position"></a>
    Your thingy is saved.
</c:if>

So if you submit your save action, the screen will automatically jump to the "Your thingy is saved" message.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜