You really, really should read:
http://cwiki.apache.org/WICKET/working-with-wicket-models.html
On 3/17/08, Fatih Mehmet UÇAR <[EMAIL PROTECTED]> wrote:
>
>
> I am newbie on wicket and it is starting to impress me.
> It is a perfect web framework.
> Thx everyone.
> Fatih
>
>
> final ListView productPropertyList = .....
>
> Found it :)
>
>
> ListItem item = (ListItem) productPropertyList.iterator().next();
> DropDownChoice d= (DropDownChoice) item.get("dropDown");
> System.out.println(d.getInput());
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: Fatih Mehmet UÇAR [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 17, 2008 9:32 PM
> To: '[email protected]'
>
> Subject: RE: ListView Problem (contains varying number of components inside)
>
> Hi Michael,
>
> Thanks for your reply. I have looked closer just after sending the email
> found the problem and fixed it same as you have told. The new problem I am
> facing is, how to get the selected values of the select boxes. Would you
> please give me an idea on how to do this.
>
> Thx.
> Fatih
>
> -----Original Message-----
> From: Michael O'Cleirigh [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 17, 2008 8:52 PM
> To: [email protected]
> Subject: Re: ListView Problem (contains varying number of components inside)
>
> Hi Fatih,
>
> The problem is that you have not set a model on your drop down choice so
> there is a null model which causes the exception you see to be generated.
>
> Caused by: java.lang.IllegalStateException: Attempt to set model object on
> null model of component:
> productProposalForm:productsPropertyListView:0:dropDown:dropDown
>
>
> Setting a default model on the dropdown choice should fix your problems.
> i.e. add a 'new Model()' as the second argument to the DropDownChoice
> constructor
>
> public class NestedDropDownPanel extends Panel {
>
>
> public NestedDropDownPanel(String id,int productPropertyId) {
>
> super(id);
>
> ProductPropertyOptionDAO productPropertyOptionDAO = new
> ProductPropertyOptionDAO(productPropertyId);
>
> DropDownChoice dropDownChoice=new DropDownChoice("dropDown",
> new Model (), new
> Model((Serializable)productPropertyOptionDAO.getResultList()),new
> ChoiceRenderer("name"));
>
> dropDownChoice.setRequired(true);
>
> add(dropDownChoice);
>
> }
>
>
>
> Mike
>
>
> >
> >
> > Hi,
> >
> >
> >
> >
> >
> > I am using a ListView to render the dynamic number of select boxes and
> > their options.
> >
> > Hi Fatih,
> >
> >
> >
> > The problem is that you have not set a model on your drop down choice
> > so there is a null model which causes the exception you see to be
> > generated.
> >
> >
> >
> > Setting a default model on the dropdown choice should fix your
> > problems. i.e. add a 'new Model()' as the second argument to the ddc.
> >
> >
> >
> >
> >
> >
> >
> > public class NestedDropDownPanel extends Panel {
> >
> >
> >
> >
> >
> >
> >
> > public NestedDropDownPanel(String id,int productPropertyId) {
> >
> >
> >
> > super(id);
> >
> >
> >
> > ProductPropertyOptionDAO productPropertyOptionDAO = new
> >
> > ProductPropertyOptionDAO(productPropertyId);
> >
> >
> >
> > DropDownChoice dropDownChoice=new DropDownChoice("dropDown",
> new Model (), new
> >
> > Model((Serializable)productPropertyOptionDAO.getResultList()),new
> >
> > ChoiceRenderer("name"));
> >
> >
> >
> > dropDownChoice.setRequired(true);
> >
> >
> >
> > add(dropDownChoice);
> >
> >
> >
> > }
> >
> >
> >
> >
> >
> >
> >
> > Mike
> >
> > I have added all select boxes into a ListView object and listView into a
> > form and trying to calculate a final price using all selected values from
> > select boxes.
> >
> >
> >
> > However, when I submit the form I got an exception before the execution of
> > onSubmit() method.
> >
> >
> >
> > I am doing sth wrong but I could not find. Would u please give me some
> idea
> > about how to overcome this problem.
> >
> >
> >
> > Thx.
> >
> > Fatih
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > I have a database design similar to below one.
> >
> >
> >
> > Product names are coming from db
> >
> > and all products have diffrent kind of Properties
> >
> > And each property have options
> >
> > all also coming from db (choices in the select boxes).
> >
> >
> >
> >
> >
> > Product
> >
> > ------------
> >
> > Id
> >
> > Name
> >
> >
> >
> > Eg.
> >
> > Audi A3
> >
> > Audi A4
> >
> > Audi A6
> >
> >
> >
> >
> >
> > ProductProperty
> >
> > ----------
> >
> > Id
> >
> > Name
> >
> >
> >
> > Eg.
> >
> > Engine Type.
> >
> > .
> >
> > .
> >
> >
> >
> >
> >
> > ProductPropertyOption
> >
> > -------
> >
> > Id
> >
> > Name
> >
> >
> >
> > Eg.
> >
> > 1.6lt
> >
> > 2.0lt
> >
> > 1.9lt Diesel
> >
> > .
> >
> > .
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > StackTrace:
> >
> >
> >
> > org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of
> > interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted
> at
> > component [MarkupContainer [Component id = productProposalForm, page =
> > com.cooldatasoft.page.proposal.ProductMenu, path =
> > 1:productProposalForm.ProductMenu$ProductProposalForm, isVisible = true,
> > isVersioned = true]] threw an exception
> >
> > at
> >
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.j
> > ava:194)
> >
> > at
> >
> org.apache.wicket.request.target.component.listener.ListenerInterfaceRequest
> > Target.processEvents(ListenerInterfaceRequestTarget.java:73)
> >
> > at
> >
> org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(Abstra
> > ctRequestCycleProcessor.java:90)
> >
> > at
> >
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:116
> > 6)
> >
> > at org.apache.wicket.RequestCycle.step(RequestCycle.java:1241)
> >
> > at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1316)
> >
> > at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
> >
> > at
> > org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:354)
> >
> > at
> >
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
> >
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> > FilterChain.java:235)
> >
> > at
> >
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> > ain.java:206)
> >
> > at
> >
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> > va:233)
> >
> > at
> >
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> > va:175)
> >
> > at
> >
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
> > )
> >
> > at
> >
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
> > )
> >
> > at
> >
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> > :109)
> >
> > at
> >
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
> >
> > at
> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> >
> > at
> >
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
> > 11Protocol.java:584)
> >
> > at
> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> >
> > at java.lang.Thread.run(Unknown Source)
> >
> > Caused by: java.lang.reflect.InvocationTargetException
> >
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >
> > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> >
> > at java.lang.reflect.Method.invoke(Unknown Source)
> >
> > at
> >
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.j
> > ava:183)
> >
> > ... 20 more
> >
> > Caused by: java.lang.IllegalStateException: Attempt to set model object on
> > null model of component:
> > productProposalForm:productsPropertyListView:0:dropDown:dropDown
> >
> > at org.apache.wicket.Component.setModelObject(Component.java:2850)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.j
> > ava:1016)
> >
> > at
> org.apache.wicket.markup.html.form.Form$19.validate(Form.java:1750)
> >
> > at
> >
> org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(Form
> > .java:160)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrde
> > rHelper(FormComponent.java:402)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrde
> > rHelper(FormComponent.java:389)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrde
> > rHelper(FormComponent.java:389)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrde
> > rHelper(FormComponent.java:389)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrde
> > rHelper(FormComponent.java:389)
> >
> > at
> >
> org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrde
> > r(FormComponent.java:366)
> >
> > at
> >
> org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.ja
> > va:1026)
> >
> > at
> >
> org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Fo
> > rm.java:1742)
> >
> > at
> >
> org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:
> > 1709)
> >
> > at org.apache.wicket.markup.html.form.Form.process(Form.java:831)
> >
> > at
> > org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:773)
> >
> > ... 25 more
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > final ListView productsList = new ListView("productsPropertyListView",new
> > Model( (Serializable)(new ProductPropertyDAO(productId)).getResultList())
> )
> > {
> >
> > public void populateItem(final ListItem item) {
> >
> > final TbProductProperty productProperty =
> > (TbProductProperty) item.getModelObject();
> >
> > item.add(new
> > Label("productPropertyName",productProperty.getName()));
> >
> > item.add(new NestedDropDownPanel("dropDown",
> > productProperty.getId()));
> >
> >
> >
> > }
> >
> > };
> >
> > productsList.setReuseItems(true);
> >
> > add(productsList);
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > public class NestedDropDownPanel extends Panel {
> >
> >
> >
> > public NestedDropDownPanel(String id,int productPropertyId) {
> >
> > super(id);
> >
> > ProductPropertyOptionDAO productPropertyOptionDAO = new
> > ProductPropertyOptionDAO(productPropertyId);
> >
> > DropDownChoice dropDownChoice=new
> DropDownChoice("dropDown",new
> > Model((Serializable)productPropertyOptionDAO.getResultList()),new
> > ChoiceRenderer("name"));
> >
> > dropDownChoice.setRequired(true);
> >
> > add(dropDownChoice);
> >
> > }
> >
> >
> >
> >
> >
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > <form wicket:id="productProposalForm">
> >
> > <table><tr><td>
> >
> > <fieldset>
> >
> > <legend>Product Proposal</legend>
> >
> > <font color="RED"><span
> > wicket:id="feedbackPanel"/></font>
> >
> > <table>
> >
> > <tr
> > wicket:id="productsPropertyListView">
> >
> > <td><span
> > wicket:id="productPropertyName"></span></td>
> >
> > <td><span
> > wicket:id="dropDown"></span></td>
> >
> > </tr>
> >
> > </table>
> >
> >
> >
> > <input type="submit"
> > value="Hesapla" wicket:id="calculateButton"/>
> >
> >
> >
> > </fieldset>
> >
> > </td></tr></table>
> >
> > </form>
> >
> >
> >
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.2 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.2
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]