Hi, See below.
On Tue, Jan 24, 2012 at 1:56 PM, Kayode Odeyemi <drey...@gmail.com> wrote: > Hi, > > I will like to understand the dynamics behind retrieving form values when > they are submitted. > > I have the following code: > > Dashboard.html > ----------------------- > <body> > <span wicket:id='mainNavigation'/> > > <form wicket:id="searchForm"> > <label for="search">Search:</label> > <input wicket:id="searchtextfield" type="text" /> <br /> > <input type="submit"/> > </form> > > </body> > > Dashboard.java > ---------------------- > public class Dashboard extends BasePage { > > private static final Logger log = > Logger.getLogger(Dashboard.class.getName()); > > public Dashboard() { > super (); > final SearchForm searchForm = new SearchForm("searchForm"); > add(searchForm); > } > > public Dashboard(IModel model) { > super(model); > } > > private class SearchForm extends Form implements > IFormSubmittingComponent { > TextField searchtextfield; > Search search = new Search(); > > public SearchForm(String id) { > super(id); > add(searchtextfield = new TextField("searchtextfield", new > Model() { replace with: new PropertyModel(search, "text") > > @Override > public Serializable getObject() { > return search.getText(); > } > > @Override > public void setObject(Serializable object) { > search.setText((String) object); > } > })); > } > > @Override > public boolean getDefaultFormProcessing() { > return false; > } remove this method > > @Override > public Form<?> getForm() { > return this; > } > > @Override > public String getInputName() { > return "searchtextfield"; > } > > @Override > public void onSubmit() { > > //String value = (String)searchtextfield.getModelObject(); > String value = searchtextfield.getValue(); > log.log(Level.INFO, "Search value is: ", value); > > // Using SolrJ to make the request to Solr > String url = "http://localhost:8983/solr/"; > try { > // Connect to Solr Server > SolrServer server = new CommonsHttpSolrServer(url); > //server.query(null, METHOD.GET); > SolrQuery solrQuery = new SolrQuery(value); > QueryResponse response = server.query(solrQuery); > > // log the response > log.log(Level.INFO, "Search result is: ", > response.toString()); > System.out.println("System print. Response is: " + > response.toString()); > } catch (MalformedURLException ex) { > > Logger.getLogger(Dashboard.class.getName()).log(Level.SEVERE, null, ex); > } catch(SolrServerException sse) { > > } > } > } > > } > > Search.java > ----------------- > public class Search { make this Serializable > > private String text; > > public Search() { > } > > public Search(String text) { > this.text = text; > } > > public String getText() { > return text; > } > > public void setText(String text) { > this.text = text; > } > } > > I really don't know what I'm doing wrong as I can't seem to be able to > retrieve the value entered into the textfield. > > Any help will be much appreciated. > > Thanks > > -- > Odeyemi 'Kayode O. > http://www.sinati.com. t: @charyorde -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com