New to Wicket and have read all the tutorials and looked at all the sample code and searched on list serve discussion for the topic.

Has any thought or code been put in place to allow the use of XPATH and a DOM tree as a DataModel. If the Presentation layer of the data follows the XML layout then it would reduce the need to write a java class to model the data and associate the view.

If you had a read only phone book application where you have the normal data elements that go with a phone book


Steps for phone book application:

1. You would load the XML data into a DOM object using say JDOM.

2. Create a custom search page to hide the XPATH syntax but would prompt for values from the user. Could be automated but hand coding would not be a problem. The user is looking for Last Name: Smith so the XPATH would be

List result = parentElement.selectNodes(/PhoneBookEntry[LastName='Smith'])

This would return a list of Elements that match the search. In this case it would be one entry but if the search was

List result = parentElement.selectNodes(/PhoneBookEntry[FirstName='John'])

would return two results. The user would see a results page and would then click on the link of interest. The results page would also be driven by XPATH for displaying summarized results of key child elements based on the needs of the application. When the user clicks on the link the parentElement for that result is passed to a panel to view the data. The data model for the panel would be driven by XPATH and the parentElement to associate the data with the view. In defining the panel you would want to do something like this.

add(new Label("First Name", new XPATHModel(parentElement, "[FirstName]"));
add(new Label("Last Name", new XPATHModel(parentElement, "[LastName"]));
add(new Label("Phone Number", new XPATHModel(parentElement, "[PhoneNumber"]));

This would be all that is required to show the results on the page. You also get the power of XPATH as your search expression. You could also provide an option to pass a defined instance of java.util.Formatter to handle the presentation of the data. It appears that future versions of XPATH may include indexing and compilation of the XPATH search expression so long term performance for huge data sets would not be a problem. When the data is properly organized XPATH is very fast. For example I would not put 1 million phone book entries as the children of one node. But would take the rational index of say last name and make that a child node of the parent with entries that share the same last name as children of that node.

The same approach would also work for updating the data but would require additional support code but it should be less if you had to write a custom model.

My challenge is the learning curve on wicket and hard deadlines I am working on as part of research for my PhD dissertation. If someone on the list could get me to a good starting point(example code that follows the same concept) with thoughts and/or observations on why this would or would not work I would appreciate it.

I have the need to display a large amount of genetic data that is organized via XML and trying to avoid writing a custom data model for each object entity. Would much rather describe the model with XPATH.



This email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
Wicket-develop mailing list

Reply via email to