Hi all,

I browsed a lot of wicket example and searched through many articles,
but never found this classical web application example : I would have on
the same page a form with some criteria, a search button and a result
list : I enter some data, hit search and get the results under my
criteria, just like google does.

No problem for me to define all these parts using wicket components, but
I don't know how to manage the workflow, and  especially what code
should I put in my form's onSubmit method.

Here is a sample code :

public class TestPage extends WebPage {
        public TestPage() {
                super();
                createComponents();
        }

        @SuppressWarnings("serial")
        protected void createComponents() {
                final WebMarkupContainer datacontainer = new
WebMarkupContainer("data");

                Form<SearchParameterBean> searchForm = new
Form<SearchParameterBean>("searchForm",
                                new
CompoundPropertyModel<SearchParameterBean>(new SearchParameterBean())) {
                        @Override
                        protected void onSubmit() {
                                SearchParameterBean searchParam =
(SearchParameterBean) getModelObject();
                                // get contract list in a
LoadableDetachableModel, but can't give it to ListView
                                IModel<List<ResultParameter>>
contractListModel = new LoadableDetachableModel<List<ResultParameter>>()
{
                                        @Override
                                        protected List<ResultParameter>
load() {
                                                List<ResultParameter>
contractList = manageContract.getContracts();
                                                return contractList;
                                        }
                                };
                                // This is working, but I must have an
inner class and final WebMarkupContainer datacontainer
                                // What to do if I want to create a
class ConsultForm extends Form<SearchParameterBean>
                                datacontainer.setVisible(true);

                        }                                       
                };
                searchForm.add(new TextField<String>("Id"));
                add(searchForm);

                datacontainer.setVersioned(false);
                datacontainer.setVisible(false);
                add(datacontainer);

                // here I do not have access to my contractListModel
                PageableListView<ResultParameter> listView = new
PageableListView<ResultParameter>("contracts", contractListModel, 10){
                        @Override
                        public void
populateItem(ListItem<ResultParameter> listItem) {
                                ResultParameter contract =
listItem.getModelObject();
                                Label name = new Label("Name",
contract.getName());
                                listItem.add(name);
                        }
                };
                datacontainer.add(listView);
        }


The questions I have are :
- How to pass model between the onSubmit() message which defines it, and
the FormView which shows itin the page ?
- Do I have to define a setResponsePage() in my onSubmit() ? If I do so,
I must go to another page, and then I lost the user's choosen criteria
- What is the best practice to build such an application ?
- Is there somewhere an example with criteria and results on the same
page ?

Thank you very much,
Bernard

*********************************
This message and any attachments (the "message") are confidential and intended 
solely for the addressees. 
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration. 
France Telecom Group shall not be liable for the message if altered, changed or 
falsified.
If you are not the intended addressee of this message, please cancel it 
immediately and inform the sender.
********************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to