I am using wicket in my web application.
Assuming I have pages a b c where I move from A to B using page parameters change somthing in page B model using ajax and B to C (without using page params).
problem :
The scenario is moving A->B->C while changing page b model and pressing the back button
B<-C
beacuse when page B instance (B1)was generated I used get parameters , therefore a new page B instance was generated(B2) I would like to return every time to page B
is there a wicket style solution to this problem ?
thank u for getting this far in my post :).
As far as I get your post, you would like to return to page B with the model that you got at B1?
The issue you should solve is how the model is persisted in Page B. If you create a new model from the PageParameters (I guess that is what you have as your Page gets 'recreated') you will loose the ajax changes. I think you should persist your model changes somewhere and reload them (for example a LoadableDetachableModel)
Related
We are facing StalePageException very frequently. I tried debugging on locally by adding debug point in getStoredPage() method just before this code and then i tried another request for same flow . The render count is not updated but on production i could see this issue.
Can any one help what is causing this and how can i reproduce .
if (renderCount != null && pageInstance.getRenderCount() != renderCount)
{
throw new StalePageException(pageInstance);
}
StalePageException is usually being thrown when the user opens several browser tabs/windows for the same page instance, for example by copy/pasting the current url from the address bar. Then making some more requests in one of the tabs and then trying to use one of the other tabs.
Wicket makes this check so that the user do not use a stale page instance. Imagine a page that shows the details of some entity. If the user deletes this entity in tab1 then (s)he should not be able to edit the same entity in another tab.
I currently have an Angular 2 app where the user can submit a form to create a new item. When the submit button is clicked, it calls a function that sends the data to the server and navigates to a new page when the server confirms that the data has been saved successfully.
My problem comes because the form submission appends the form parameters to the URL. So for example if I had an input named title and submission took me to the route mytitle which is the input for the title field, Angular (or whatever injects the GET parameters) would try to navigate to mysite.com/mytitle?title=mytitle instead of just mysite.com/mytitle. Even adding [ngModelOptions]="{standalone: true}" to all of my inputs still leaves a question mark with no parameters after it.
This is a problem because it causes Angular to reload the app because the given route does not match any routes in my route definitions. Is there a way to disable the GET parameters being injected into the URL entirely? POST doesn't work either because I have nowhere to post to, and my next URL uses data from the form itself.
I found an answer to my question, the "Submit" button defaulted to being of type "submit", so changing it to type "button" removed the GET parameters injection behavior.
Check setValue in your form control. Example: Set value this way this.form.controls['val'].setValue='' rather than assigning an empty value
(i.e. this.form.controls['val'] == 0).
If your problem still exists, kindly add button type submit to the button and manually give the click function access to it.
I'm using GTM and I need sending several values for each web/product.
In a specific web I've a lightbox to get some data from user and need to send a "conversionValue" with a different value when the user finish the task.
When I try to do this by using dataLayer.push it just add a new object to the original dataLayer (as it is in a fancybox loaded by ajax, not iframe, it gets the "parent page" dataLayer), so I get a dataLayer with many objects and only the last one has the correct "conversionValue".
The problem is, if I try to use this variable from GTM, it gets the first object to look for the conversionValue...
Should I clear the dataLayer before pushing new objects? Am I doing it wrong? Is there any other way to do this?
After reading about Google Tag Manager, it doesn't matter if you add new objects to dataLayer because their variables can't be readed from GTM the same way as you read them for the first time.
You have to read new values by defining events.
Im pretty new to ASP.NET MVC, trying to figure out my way around.
Currently i return a ViewModel which has a IEnumeable Events as its only property. This ViewModel is StronglyTyped to a UserControl which dislays the IEnumable Events in tabular form.
One of the properties of the Event Model is an XElement, which contains some XML loaded from the DB.
Now i've added a link to the end of the tablular data to be able to view the XML in a separate page. How do i pass this data to another page for viewing?
I would post a request back to the server with some sort of Id for the Event-object and have the receiving end send back the XML related to that Id.
if you're looping through the Event objects in your IEnumerable, you can do something like:
<%= Html.ActionLink("GetXml", "Events", new { id = currentEvent.Id }) %>;
Now create an Action on your EventsController (given that you have one) like so:
public ActionResult GetXml(int id)
and retrieve the XML to pass back to the View
There are basically two ways of bringing data from one page to another using ASP.NET MVC (or any other language/framework which follows the HTTP protocol):
Sessions: Use a session to store the data you need, and load it back up at the next page.
Post the needed data back to the server. This way, the server can hold it and display it on the next page. Posted data usually comes from input or textarea elements. If you use input type="hidden" you can give it a value which represents your data. This way, you can post it back and forth till you arrive where you want.
Besides what Arve is advising, you could also consider TempData.
If you use the Get-Post-Redirect/Forward concept for you app, you could do something like:
GET - Initial Request comes in, Server responds with View and model data. User selects an item which leads to ...
POST - User selects one of the items from #1, triggering a post. That particular item can be fetched from repository, placed in TempData and then...
REDIRECT/FORWARD - The redirect collects the information out of TenpData and uses it as the model for the new View.
here is an example http://www.eworldui.net/blog/post/2008/05/08/ASPNET-MVC-Using-Post2c-Redirect2c-Get-Pattern.aspx
I am using T4MVC to redirect to another action return RedirectToAction(MVC.MyController.MyAction());.
In result it is doing get request.
Is there any way to make post request from controller. I want to keep all the same but only make post instead get. I cant find any methods for that. I found one post helper here http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx but i cant pass any values i need using this post helper. I was trying to pass values through TempData but they are not coming when i using this helper. May be some one have any ideas?
The reason i want to do this because when user come from one controller to another and then if user click update or just click enter in browser address bar, page will break.
Should i use session for that reason?
A RedirectToAction will always perform a GET, never a POST (it returns a HTTP 302 to the browser, which will then issue a GET request).
To persist data across the redirect, if it is data that can be easily represented as a string and stored in the query string, then you can just add it to the route values of the redirect.
e.g.
return RedirectToAction("Search", new { searchString = "whatever" });
If it is a complex type, then you will need to store it in TempData. A number of other questions on StackOverflow (such as this one) give details on how.
If repeatedly storing to and reading from TempData across your application offends your code-sense, then you can encapsulate this by using the PassParametersDuringRedirect attribute and generic RedirectToAction available in the MvcContrib project. Some details on this technique are available here.
only way of doing post is by having a form and doing submit on that form, either with a submit button or with javascript, any info you want passed to that action must be in that form and you will find everything posted in FormCollection(hope I spelled it right).