grails using pagination with form submission - forms

I am new to grails, right now I'm stuck with a page of form submission, which contains the pagination inside it. My purpose is to create a form submission of 2 or 3 pages which made from pagination. If I were in page 1, selected the input which used g:radio, then I go to page 2 and checked for the other input but if I want to go back to page 1, everything must be the same as I checked before i go to page 2. Could anyone please give me a guide how to do it? Thank you and welcome for any responses.

What you probably want is called "Spring WebFlow". Each flow has a start and one or more ends and unlimited number of steps in between. Grails has a nice DSL to define flows, transitions and more.
Spring flow for Grails is well documented at http://grails.github.io/grails-doc/2.3.0/guide/theWebLayer.html#webflow.

Related

How to create a "waiting" queue when there are more than 2 visitors on the website

Hello,
I use a form on my website. This form contains content that can only be selected once.
I would like to create some sort of "queue" when there is more than one visitor on the page.
So for example 2 visitors:
visitor 1 -> fill in the form.
visitor 2 -> gets popup with "please wait"
visitor 1 -> sends the form.
system processes data from form.
visitor 2 -> make popup invisible and show form.
Or another option would be to check if someone else has checked the checkbox yet and give a message if someone has checked this yet.
Well, as you didn't provide any code I will just give you my humble thoughts on this.
First of all: May I ask why? This sounds like a horrible user experience...
If you really want to do it anyways, here's what you need: AJAX or jQuery to provide the live feedback popup you mentioned. For the visitor count caching part there are obviously many ways to do it like using scripts of any kind or even some file or database based solution. From that point on you just go with your favorite web language and code the main queue logic, I would recommend PHP with a breeze of JavaScript.
I hope this was at least a little bit helpful.
Kind regards

News Component Requirement

We have a requirement to create a News Component. So there will be news pages which we will author contains Title, Image & description. I will store this under one node say content\myproject\newsnode\news1,news2 like this.
On the homepage, I want to show the latest 3 authored news description. For that, I'm thinking of using a news component.
I thought of creating 2 component and map them. Thinking of using the Query builder to fetch the latest news to show on homepage. One component of news page and one component on a homepage to show latest 3 news with Title, Tile image and a small description.
Is there any other approach to this?
If you are using a dispatcher, querybuilder servlet is blocked by default and should be blocked for obvious reasons.
Since your question is general, I will try to answer generally and on a high level.
There are two possible options I can think of:
1. make a servlet to retrieve the last 3 news component information and expose them as JSON. Then send an AJAX request from your browser and change the view accordingly with jquery or your front-end framework of choice.
Advantages: No caching, you'll always get the latest news.
Disadvantages: SEO, if you care about that in this case. Search engines will
not index the news on the page since they are not part of the initial markup (not server-side rendered)
2. Create a service to get the last 3 news component info then render them on your component via HTL or JSP. Basically server-side render them.
Advantages: SEO, same as the reason above.
Disadvantages: You have to invalidate the cache for your page every time a new news component is added to make sure your end users get the latest.
Hope this helps.

How to link multiple pages in GWT

I am new to GWT and so my knowledge is restricted.
Right now I have created a simple Login page which will take my user to another page and then based on the choices that the user makes, it will direct it to the next page. I have created 3 individual pages but I have no clue how to link them. Can someone please help.
In GWT typically you do not create separate pages - you create separate "views". They may look like pages to an end user, but in reality the entire app works in a single HTML "host" page.
You may want to look at the Activities and Places design pattern. It takes care of navigation between different "places" within your app.
very simple example with a DeckPanel. It shows only the selected 'page' and hides the other ones
DeckPanel deckPanel = new DeckPanel();
deckPanel.add(page1);
deckPanel.add(page2);
deckPanel.add(page3);
deckPanel.showWidget(0);
//deckPanel.showWidget(1);
//deckPanel.showWidget(2);

Spring 3 MVC multi page form with session attributes, cannot go back

I wrote relatively simple web app in Spring MVC. I have following multipage forms:
Fill in
Check preview and eventually go back to 1. by form button or back button in your browser
Confirm
I used annotation #SessionAttributes and everything goes well, besides of going back to edit form after preview.
Then I have an information that document has expired in browser and I have to renew my POST request hence creating new objects. I resolved this problem by creating another method which loads view with form and loads there information from session, but still I can't use 'back button' in my browser. I would like to avoid javascript in this problem. Any ideas?
EDIT: I can see when session is active header is always set to 'no cache no store', maybe there is a way to configure Spring Session to enable cache and store? I searched but didn't find anything helpful.

check user availability in forms in jsp

I have a jsp form which takes in user details. On submit button it goes to a jsp page where the details are entered into the database. But before that I would like to check if the username is available as soon as the user clicks the check availability button. How can this be done?
2 ways:
Just redisplay the same page after submitting the form wherein you conditionally display the validation message. This is rather trivial and already covered in the Hello World example in our Servlets wiki page.
Use Ajax to send an asynchronous HTTP request and manipulate the HTML DOM based on the response of the request. This requires a bit more in depth understanding of how websites really work and what JavaScript is. You can find some concrete examples in How to use Servlets and Ajax?
Use AJAX(Asynchronous Javascript and Xml). Its the best web2.0 technology. You can manipulate DOM based on the answer from server