Is there a way to give my links all variables in an object? The purpose of this is to make the links book-markable. The important information to re-build the screen will all be in the URL.
My work-around introduces a session and url re-writing. This is a link that will add or change the industry variable in my object s:
<a href="@{Stocks.index()}?s.industry=${roeBean.industry?.urlEncode()}">
When the link is clicked, Stocks.index is called accepting the object s as its parameter. That receives the s.industry data and all other values in s are null. So, I can then merge the s parameter with another copy of s saved in the session. The cache is then updated and the URL re-written.
It works great, but it would be more elegant if the play framework had something to simply expand the state object and change a variable (just for the link). Is there an clean way to do this? I imaging this would be very useful.
Would just creating a new controller method (not index) for the purpose of just updating industry work? The follow will work when passed the s.id and the s.industry to be added (or if exists replaced if that’s what you’re looking to do).
In your view:
(send the view the s object but it seems like you do that now) (also, I’m using the groovy template helper, you can use the html if you want, same results)
In your controller:
(Replace String with whatever Industry is)
Passing a static string here (or other stuff) works too. so s.industry=’test’ will GET id=1 and industry=test in this example.
If you want your links to have all properties of an object, can you not just send the whole object? Passing the entire key/value bit of every property in an object seems like a lot of work if you just want the entire object? So in this example:
when you render the view from your controller
the link?
In your controller to save: