Back to previous view-sate after action state - spring-webflow

I'm using Spring webflow for my product. In current view-state I have a transition to a action-state to decide which states to go next. However, there's a case requiring to stay at current view-state after action-state. I treated it the same as other states but it caused a reload of my current page. I don't want that. Is there any other way to do this ?

The fact that your page reloads is normal because webflow sees this as an exit of the view-state when transitioning to the action state and a re-entry of the same view-state when leaving the action-state again. So to avoid the reload you have to avoid leaving the view-state in the first place. There are several way to do this. The simplest way I can think of is to use an EL expression to select the target state directly from the transition element, instead of putting that logic in a separate action-state:
<view-state id="bla">
<transition on="submit" to="#{someAction.selectNextStateId()}" />
</view-state>

Related

FullCalendar: is there still a viewRender event hook?

I need something like the viewRender event in order to persist the user's state. I'm building a UI where users will frequently jump in and out of the calendar, so preserving their view/range is essential for a pleasant experience. Does this exist in v5? The last mention I can find of it is from v3.
The only workaround I can think of right now is a direct click handler on every view control element, or a very heavy-handed MutationObserver. This is a React app so either one is going to be super awkward.
Thank you!
Edit 2021-02-11:
I looked at the available view render hooks but none of them address my problem. What I need is an event that will fire whenever the view state changes, including clicking between weeks/months/etc., so that I can persist the date range the user most recently viewed as well as the view they had selected.
viewDidMount is the closest to what I need, but it does not fire when the date range changes.
Edit 2021-05-26:
Another problem with using viewDidMount is that using it to enact side-effects is a bit overeager. The hook gets called whether or not the user has actually done anything, and the default view always gets passed as view inside the View Object. So there's no way to tell whether this mount event contains data I should persist or not.

JQuery/ ASP.Net - How to Maintain the State of Hidden UI Elements across Postbacks?

I'm working on a webform with various controls. Depending on user-input I show/hide (using JQuery's show()/hide() functions) bits of the GUI. However if the form is posted-back and fails validation, I want the GUI to remain in the same state it was pre-postback rather than returning to the first-load state. Obviously the ASP.Net controls retain state, but I have HTML containers that are pure client-side objects.
In attempting to design a solution I find myself heading towards the murky (and tricky-to-debug) realms of hidden form fields - more reminiscent of my pre-JQuery work than anything 21st Century :-(
Can anyone suggest a better way ...?
If anyone's reading this:
I went with a JQueryish solution - a JS function now runs onready. It checks the state of any ASP.Net controls which act as 'visibility controllers' (which obv. maintain their own state across postbacks) and sets the UI accordingly via JQuery calls.
I think the trick is to use the hidden fields to persist the state of the client-side fields.
So the process is something like:
user action -> update hidden value(s) -> update UI
Then when the page posts back, you re-set the UI:
page load -> update UI

Caching the whole page so it looks the same when using the back button

I am talking about list pages in which I am using many filters. Actually these filters are in a user control and are ajaxified. Can I cache the state of the page after applying say 4-5 filters, so that if I move to another page after applying these filters and then return to the original page by pressing back button I will see the same filtered state of the page? I am not changing the url after applying any filters. Can this be done by output caching?
What you're asking for really has nothing to do with caching. Well, it does, but not the kind of caching I think you're talking about :-) FireFox has what is known as the bfcache, which stores the state of a page's DOM as it was when you navigated away from that page. This is used so that when you return to the page, it will look the same as it did when you were there last.
However, certain events cause the bfcache to not be used. For example, this question details how the unload event affects things. If I were you, I would revisit the "I am not changing the url after applying any filters" statement -- I would reccomend storing the state of the page in a docuemnt.location.hash. Here's a question which details that concept

ASP.NET MVC Render Ajax / Standard View

I am a little confused and making it alot more complicated than this needs to be! Here is what I have...
A view which displays a drop down of US States. When the user chooses a state it loads a list of data from a database and returns the results (populates the View Model) and the View renders the information.
What I wanted to do was have have the dropdown trigger an Ajax event which performs the data load, but also wanted it to depreciate if the user didn't have Javascript enabled. How would I go about rendering the view with AND without javascript / ajax?
Hope that makes sense. Thanks for your help.
You can't re-populate a drop-down without jscript. You can do a page-reload with a new drop-down though, although the logic to determine which to use is javascript unfortunately. (Not to mention triggering the re-load of the page on click)
No Javascript support though? That seems kind of out of date, most people run javascript-enabled browsers these days. As for paranoia freaks with javascript turned off, a <noscript> block to tell them to get over it may be appropriate.
To do this with ajax, read this article about cascade dropdowns by Stephen Walther.
To do this without ajax, you could put your first dropdown in a form with a button visible only when javascript is disabled (hide this with javascript for that) wich gets to some action (in another window, maybe) wich returns the second dropdown populated according to the element selected on the first (on the first window, if you have 2 - you could know this url using a viewstate variable).

Why does my session variable appear to empty itself in ASP.NET?

I have user control on a ASP.NET web page, which contains a GridView and a radio button selector.
In the underlying middle tier I have a thread which goes to the database and then raises an event to say "I have some data" my User control handles this event and sets a Session Variable.
This works and I can see the event being handled and the Session variable gets the new data.
However when i go to use this session variable when the selected index of the Radio button selector changes the Session variable reports as "Nothing"
I have ensured that the obvious (i.e. spelling, Sessions switched on etc) are correct.
The GridView and radio button selector are encapsulated in the same Update panel.
Check that if your UpdatePanel - updatemode is set to 'Conditional'? also Child as triggers? I would first start by putting a stop in your page load, see whats happening from there. Do a search for all places where you populate that session variable and put a stop. You may be surprised, I have often found that page lifecycle gets confusing even though I thought I understood it. Alt - post some code and we can step through.
Yeah, sounds almost like a problem with order of operations or not checking for postback on a page load or something?
Like JamesM suggested, running your website in debug mode should really help identify the problem. You can bring up your watch window and set it for the Session variable you're looking for, then set breakpoints all over and check the value at each stop to divide and conquer the code.

Resources