Changing url with parameters in gwt framework - java

Could someone give me an example how to use celltable in case I would like to change url?
I have a simple celltable -
On session select I would like to change url to something like this -
localhost#main?sessions=20,21
I have already read about placeControllers and etc.
But I don't find any example of using url with parameters.
What I have to do when select event is calling?
What I have to do when place(history) event is calling?

Using history token in GWT is quite simple, just read little bit about it here.
Basically when you want to change history token, just build string you want and use History.newItem(token). Not sure what do you want to do afterwards, but usually you have to register handler with History.addValueChangeHandler() to react to new "state"
To find out actually selected items, you need kind of selection model. But not sure when do you want to trigger the change..

Related

How to save state of GET request url java spring rest

I have RESTful app which reacts on GET request and I need to store the state.
For example
localhost/subs?search=John
Then I need to add other parameter division by clicking button.
localhost/subs?search=John&division=develop
Meanwhile the data output will be distributed on pages. And appear new 2 parameters size and page.
localhost/subs?search=John&division=develop&size=5&page=0
In this situation when I click on next page button my url is resetting.
I’m really confused. How to save state and if parameter is already has in url then it should be changed for new value, if parameter doesn’t exist then append it.
If there good options?
At least I can use JavaScript by taking it and parsing url.
But I think it’s not good at all.
As I know, the RestAPI doesn't save any request parameters (Maybe you can do by adding them into a session attribute, but it's just made the logic code become more complex).
At least I can use JavaScript by taking it and parsing URL
Yes, I think you should.
Happy coding!

Is it possible to "intercept" a copy/cut/paste action and replace it with my own code?

I am writing an application where I want to intercept copy/cut/paste actions and "replace" them with my own code - for example I want to be notified on a copy action and catch it, and I want to "replace" the paste-action-handling code with my own code so I can change the behaviour of what happens if the user tries to paste something in e.g. an input field.
A nice bonus would be if I can add copy- and paste-actions to fields like a choice box.
Is this possible without digging into deeply internal JavaFX code?
You can implement listeners for the short cut keys on the controls that you need to specify the copy/paste behavior. You need to listen for keystrokes of:
KeyEvent.VK_C
KeyEvent.VK_V
KeyEvent.VK_X
Each of these needs to be combined with the meta or control key mask. Then you just need to handle the clipboard.
Alternatively, you should see this question that addresses a similar issue, but the solution uses keybindings:
Java Swing: How to prevent system copy,cut,paste action?

Revert (Undo) implementation in GWT

We are trying to build a GUI framework using GWT. We are finding it hard to implement the cancel functionality in the framework.
Required feature is this:
We have CRUD screens which have pop-ups, grids and so on. When the user changes anything in the GUI and then clicks on cancel() he should be given a notification message saying that something has changed.
Approach that we have tried:
Currently we are trying to keep a hashmap of key vs value of the entire pojo object and trying to compare it against the model which gets updated as and when user changes something. But this is adding lot of unwanted code in every pojo and not working as expected when user adds data directly from the backend.
Is there any elegant way in achieving this functionality? Kindly note that *we are not using Editor framework of GWT *(https://developers.google.com/web-toolkit/doc/latest/DevGuideUiEditors) in our application.
Example:
Suppose I have a pojo like this:
public class Person {
List<Address> address;
PhoneNumber phoneData;
// and so on along with getters and setters
}
How will I write a generic clone method for this? And even if I manage to do that somehow that will lead to lot of code in every pojo (our application has hundreds of them) which doesn't seem right.
Please note that, our pojo gets updated as soon as something is changed in GUI to achieve live binding.
So you have "Save" and "Cancel" buttons in your form?
I would recommend you to change the concept. Update your object properties immediately as user edit them (as in GMail, JIRA and many other modern applications) in an OnChange event handler.
Save all updates to the session stack as UpdateAction objects and let the user undo every single property modification calling UpdateAction.undo() method.
The benefits are:
this design is much more user friendly than "Click "Edit" - update - click "Save"" scenario.
You don't need separate view/edit forms/popup dialogs - just a single form for both viewing and editing.

Java - Dynamic dropdown to country/state

In my web-application I have a the following requirement.
I need to have a dropdown for country.
Based on the country selected I need to display the corresponding states.
I need to fetch both the country and state from database.
I cant use javascript since in production(live), javascript will be disabled.
I guess I have to use ajax to implement this?
Can anyone please tell if there is any better way to implement the above requirement?
I have seen the following link.
Populating cascading dropdown lists in JSP/Servlet
But I dont like to use javascript (since my client will disable javascript in Production environment)
I cant use javascript since in production(live), javascript will be disabled.
Can't use javascript than you would have to refresh the page i.e.:
Select Country from drop-down
Provide a link or button to submit this value (click on this)
Server call, which will retrieve the Country values and also the State values for the country selected
display the JSP with the values retrieved and make the Country which was submitted pre-selected in the drop-down.
I guess I have to use ajax to implement this?
Now my friend you are contradicting your own self, because ajax (I am sorry to say this) is nothing but javascript, it is not some different language than javascript.

Multipage environment in GWT

I have been developing an AJAX web application using GWT. I've read several blogs and forums about this question and left with no clear idea. I understand that GWT is an AJAX application, that supports only stand-alone web application. By stand-alone, I meant GWT to be a single web page that would suffice the user requirements. However the use case I have is pretty complex and I'm stuck in this use case that doesn't let me proceed.
My usecase(s) goes like this:
Usecase #1: There is an order entry form where user will enter a search string to search for a particular item. With GWT, I could display the result in a table (say celltable). However, when I click a column in the cellTable, I want the value of the column to be sent to the server and display another page that will display only the details of the selected column. I'm not sure how to accomplish this.
Usecase #2: Let's say the web application I develop is called "InventoryControl" and I have different requirements such as:
display Available stock
display Order stock
display Manufactured unit
and Using Java servlets, I could just type http://localhost/availableStock?stockId=1234 on my browser to get the "Display available stock" for the given stockId and then http://localhost:orderStock?stockId=1234 to get the "display order stock" and similarly "display manufactured unit". Is the same possible using GWT? i.e. when I type http://localhost/availableStock?stockId=1234, is it possible to read the parameter being passed and then display the corresponding page?
If these are not meant to be guaranteed by GWT, should I stick with Plain old JAVA servlets/JSP?
Thanks in advance.
Ashok - Please note, what filip suggests above does not require multiple "pages" in the sense of additional html host pages. You can build a panel holding your display of the details, and swap it into the rootpanel of your host in the onSuccess() of your rpc call. The GWT history mechanism allows you to assign anchors to these "places" and provide a mechanism to map these anchors to specific display classes in your code.
GWT already has a mechanism for handling multiple page applications. Have a look at Activities and Places. You can define each page as a place in your application, and use the GWT mechanism to go from place to place at any time. Using places also allows you to easily add tokens/query parameters to each "page", in an OO manner, without having to worry about populating/querying the URL directly. Have a good read of the link!

Categories