java - Generating Hyperlink / HTML / 'Please suggest' in a loop in GWT? -
Then my question is as follows:
Say, after receiving the data in a flicktables I am from a database, it is using the loops in a regular way.
Now, in the entire first column, the text should be clickable, that is, I should add the call handler to the first column values (as I would have to load another table after clicking on the first column text vals .)
Question : How can I generate a hyperlink tag in a loop? The problem comes when I try to do this because I do not know how the loop runs and when using click handler, the same concept is used.
Should I use something other than hyperlinks for this task? How do you explain?
I really appreciate the help because I am a very new GW Coder.
- Viva
Using hyperlinks is not the best way to do something like this. Because you should not use the clickhandler with hyperlinks, a hyperlink has set up an HistoryToken and you should answer the change of history.
I will use a label and if you want to feel the same passion and feeling then it will be in style as a normal link (I will use a label in the following example, but you can convert it to hyperlink If you want.)
I will create a square that extends the label. This class will have an ID that you set in the constructor. You will send this ID to the server to receive the new FlexTable. In the constructor, you add a click handler which reads the id field and sends it to the server to get the new flaxstable.
Public class Flexible Label Spreads Label ClickHandler {int id = 0; Public FlexTableLabel (string text, int id) {this.id = id; This.setText = Text; This.addCickHandler (this); } Public Zero onClick (ClickEvent event) {// Sends id to server, of course you need to change your service with your service / service; Service .getNewFlexTable (this.id); }}
In your loop you can only create new class objects and give it the appropriate criteria (I think you have an ArrayList with the result. In this ArrayList object Text and id):
for (int i = 0; i & lt; result. Size; i ++) {FlexTable.setWidget (i, 0, new FlexTableLabel (result. Get (i) .text, result.get (i). Id);}
I hope this allows you to start at least something, if any thing is still clear If not, leave a comment And I will try to help clarify things.
Edit on this basis:
Without understanding your application, it is difficult to explain I normally apply to get a special widget, creating a class like this:
Public Static Expands Your Panel Panel {Private Fixed yourPanel Example = Zero; Public stable yourPanel getInstance () {if (example == zero) {example = New YourPanel ();} Return Example;}}
In your EntryPointClass you will have something like this:
Public class YourEntryClass EntryPoint {Public on Zero Module Load () {RootPanel.get (). Add (YourPanel. Take the Opinion ()); }}
You can now call the YourPanel.getInstance () method in the onSuccess () section of your service to change the contents of the panel:
< Code> YourService.getNewFlexTable (this.id, new asyncCallback & lt; ArrayList & lt; string & gt; & gt; () {public void onSuccess (ArrayList & lt; String & gt; results) {for (int i = 0 ; I & lt; result. Size; i ++) {YourPanel
I hope that helps. Leave a comment if it is not.
< Strong> Sample App
Comments
Post a Comment