I am new at wicket. I have a problem needs a solution. I have a data table and it contains "subject codes" like 10,10.1,10.1.2,10.10.1.3,... and also these subject codes have corresponding "subject names". What I need to do is: In my application user enters a subject code as input text area and application returns max 20 correponding subject codes as a list. User chooses one of the codes and application shows this code and it's related name at a hierarchical tree. For instance user chooses 10.1.2, tree shows this selected code as a tree. I was able to list max 20 codes and user choses one of the codes but I could not create the tree. Did anyone do something like that by using wicket?
You can use the implementation of the Wicket TreeTable:
http://www.wicket-library.com/wicket-examples/ajax/tree/simple
Start of with this example and you will get data on your screen. You can modify it so it suits your needs.
Related
I am preparing to embark on a large solo project at my place of employment. First let me describe the project. I have been asked to create a Java program that can take a CamT54 file (which is just a xml file) and have java display the information in table form. Then users should be given the ability to remove certain components from the table and have it go back to xml format with the changes.
I'm not well versed in dealing with XML in Java so this is going to be a learn and work task. Before I begin investing time I would like to know that my approach is the best approach.
My plan is to use DOM4J to do the parsing and handling of the xml. I will use a JTable to display the data and incorporate some buttons to the GUI that allow the modifications of the data through the use of some action listeners.
Would this be a plausible plan? Can DOM4J effectively allow xml data to be displayed in a table format and furthermore could that data be easily modified or deleted then resaved to a new xml?
I thought I would go ahead and answer this as I finished the program and wanted to post what I thought was the easiest solution in case anyone else needed help.
It turned out the easiest approach (for me at least) was to use the standard DOM parser, here are the steps I took.
Parsed the entire XML into String array lists. XPath was required for this, I also had to convert the elements into Strings and remove the extra tag information from the string using substrings since I only wanted the actual value.
I populated a JTable with these arrays.
Once users finished editing and clicked a save button then another Dom parser would take the original XML and change each and every attribute using the values from the Arrays (that were deleted and repopulated with the JTable cell values when the user clicked "save").
I am writing a web scraper using JSoup to take prices from the first page of search results on Amazon. For example, you search "hammer" on amazon, the first page of search results comes up, my scraper takes all the prices for each search result and shows them. However, I can't figure out why nothing is printed when I run my program. The HTML for the price figure of an item on Amazon.ca is:
<a class="a-link-normal a-text-normal" href="http://www.amazon.ca/Stanley-51-624-Fiberglass-Hammer-20-Ounce/dp/B000VSSG2K/ref=sr_1_1?ie=UTF8&qid=1436274467&sr=8-1&keywords=hammer"><span class="a-size-base a-color-price s-price a-text-bold">CDN$ 17.52</span></a>
I run my code as follows:
Elements prices = doc.getElementsByClass("a-size-base a-color-price s-price a-text-bold");
System.out.println("Prices: " + prices);
What is returned:
Prices:
How do I get the price value "CDN$ 17.52" in this case?
One way would be doc.select("span.s-price"), another would be doc.getElementsByClass("s-price").
Your code doesn't work because getElementsByClass expects a single class name, and returns all elements which have that class. You've supplied several class names, the function can't cope with that and finds nothing.
The span element you're looking for has several classes applied to it: a-size-base, a-color-price, s-price and a-text-bold. You can look for any one of these classes, and it's also possible to match elements which have all four classes by building a CSS selector like doc.select(".a-size-base.a-color-price.s-price.a-text-bold").
However, you probably want as simple a selector as possible, because Amazon are free to change their CSS styles at any time and can easily break your scraper.
The simpler the scraper is, the more resilient it is to breakage. You might want to look for prices through semantics rather than rendered style, e.g. doc.getElementsContainingOwnText("CDN$") would select elements containing the literal text "CDN$".
i was wondering a few things.
I Have a database with 3 rows, and i have to use the database on my website cause it has to be shared with every one that downloads my app cause they can add more things.
Table is called
Poka
And the rows are
- ID
- word(TEXT)
- reply(TEXT)
The Reply is hooked onto the word.
Sense there can be more then 1 of the same "word" text i need it to search threw each of the word that was inputed in the EditText and pick a random reply from that and display it in EditText . And if there are no words, it will say cannot find one.
for that you have to use text box edit listener whenever the value of text box changes call the web service that give you response depend on what you send to it and then pass that response to text box.
refer therefer the answer of the question
in above link I explain the answer with code.Using that that code you can definitely do that.
the main thing is built web service so that it give you proper response.Just return table of words from the web service then catch that table get relevant column data and show it in your application.
obj3.getProperty(0).toString();//id
obj3.getProperty(1).toString();//word
If you returning id and word nad you want only word column then you can choose
obj3.getProperty(1).toString();//word
all the answer is explain in above link.refer that too.
Please write comment if you are facing more problem in that.
I'm trying to wrap my head around this. My language is Java using PlayFramework but I think any answer using php, or ruby on rails would get me in the right direction. Basically the user can add or take away number of pallets in this form. There needs to be some javavscript calculations per tab also. Everything is fired using a input change jquery event so there is no submit buttons. My first mockup used UUID's but that seemed to get me nowhere.
What happens is each tab is reponsible for doing calculations like perimeter. My first question is how to call javascript for the specific tab. I first did it with UUID's and separate scripts for each tab. This didn't seem correct.
My second problem is submitting this data. Obviously the name parameters need to be different. So I'm scratching my head on this. Every pallet would be tagged with an id so I'm not worried about the backend as much as I'm trying to figure out how structure the front end and the controllers.
Any help would be great. Thanks.
On the javascript part, assuming all the tabs have the same structure, create a generic method that receives and id (id of the tab) as parameter, and then retrieves the proper fields form the calculation. Something like:
function doCalc(tabId){ //assumes jquery
var tab = $("#"+tabId);
var field1 = $("#"+tabId+"_field1");
var field2 = $("#"+tabId+"_field2");
//...etc to retrieve tabs
}
The method assumes that when you create a tab "tabId" and its elements, you generate the id of the elements with the formula "tabId_", which will facilitate finding them.
About the submission, using Play! you should check this section about Ajax requests. It could be as simple as doing the calculation (the method above) and at the end call a Play method via Ajax. This method would get all the parameters (id, values, etc) of a pallet (the pallet of the given tab) and save it.
For submission, I assume you are trying to figure out how to hold and pass the data in a bean. What about having a field as below:
LinkedHashMap<String, LinkedHashMap<String, Object>> field;
The inner maps would be the listing of the fields on a Pallet. The outter maps are the Pallets.
I am having a form. I want to show user suggestions about the name of the security he can enter. For the same I want to use the values of securities that I have installed in my Oracle Database.
I want to do something like this, if user enters a, he should get all security names below the text field which starts from a, when user selects anyone of them, then the text field must show the selected values.
Thanks in Advance.
You need autocomplete enabled text field. There's a tutorial how to build one. Even better, use jQuery java script library for this and many other features.
I'd suggest a trie. They are great for things like predicive text and auto complete.
Get all the valid security names and put them into the trie, then query the trie with whatever prefix the use has entered and it will give you all the matching names.
Note that Java doesn't come with a Trie implementation itself buy it would be pretty easy to write your own or borrow one, for eg from here; http://forums.sun.com/thread.jspa?threadID=5295936
Edit: You didn't say if this was going to be on the web or desktop (eg Swing)....