create a new instance of page, why would you do that. it should simply
be something like:

onsubmit() { List list=getList(); Object object=getObject(); list.getObject(); }

if everything is wired properly the page should refresh and you should
see updated info.

-igor


On Feb 3, 2008 10:40 AM, Vijay Dharap <[EMAIL PROTECTED]> wrote:
> Hi Igor,
>
> If I use regular submit button and override the onsubmit of the feeForm
> and create a new page just to display the fee Listing page
> like below,
> protected void onSubmit() {
>         log.debug("form got submitted"+getModelObject());
>         ListFees listFees = new ListFees();
>         listFees.getFeesList().add(getModelObject());
>         setResponsePage(listFees);
>         super.onSubmit();
>     }
>
> Things work properly. by that i mean, I get table with one row
> showingthe contents which i had just entered in the form. I am still to
> fgure ut how to retrieve old list from the session so that entire table
> can be replicated in more than one submis.
>
> Regards,
> Vijay Dharap
>
>
> Igor Vaynberg wrote:
> > what happens if you change ajaxbutton to regular button? does the
> > update happen properly then?
> >
> > -igor
> >
> > On Feb 3, 2008 1:41 AM, Vijay Dharap <[EMAIL PROTECTED]> wrote:
> >
> >> Hi,
> >>
> >> I am fairly new to world of wicket. so my issue might be something very
> >> trivial.
> >> I am using a simple form to input some fields. and i want to update the
> >> table below in the same page with the newly entered info in the form
> >> above. Page should not refresh. table should be updated through AJAX.
> >>
> >> Looking at various examples, I could get my ajax part working. but. now
> >> when i enter details in the form above 2nd time, the refreshed table
> >> below replaces all the old entries same as latest entry.
> >> e.g. 1st time descr was "1sst time", when i try to submit page second
> >> time with description "2nd time" both rows of table now show "2nd time"
> >> as description.
> >>
> >> Can anyone help pinpoint what i am doing wrong?
> >>
> >> Here is the code that i tried.
> >> *Fee.java*
> >>
> >> public class Fee extends WebPage {
> >>         private static final Logger logger = 
> >> LoggerFactory.getLogger(Fee.class);
> >>         private String pageTitle;
> >>         /** Container for the fees table, used to update the listview. */
> >>         private WebMarkupContainer feesContainer;
> >>         private ListView fees;
> >>         private FeeForm form;
> >>         public Fee() {
> >>                 super();
> >>                 FeeModel fee = new FeeModel();
> >>                 CompoundPropertyModel propertyModel = new 
> >> CompoundPropertyModel(fee);
> >>                 form = new FeeForm("feeForm", propertyModel);
> >>                 pageTitle = "Add Fees and listing of Current Fees!";
> >>                 fees = new ListView("fees", getFeesList()) {
> >>                         // This method is called for each 'entry' in the 
> >> list.
> >>                         @Override
> >>                         protected void populateItem(ListItem item) {
> >>                                 FeeModel fee = (FeeModel) 
> >> item.getModelObject();
> >>                                 logger.debug("fee" + fee);
> >>                                 item.add(new Label("description", 
> >> fee.getDescr()));
> >>                                 item.add(new Label("type", fee.getType()));
> >>                                 item.add(new Label("capitalized", 
> >> fee.getCapitalized()));
> >>                                 item.add(new Label("taxable", 
> >> fee.getTaxable()));
> >>                                 item.add(new Label("amount", 
> >> String.valueOf(fee.getAmount())));
> >>                         }
> >>                 };
> >>
> >>                 add(form);
> >>                 TextField descr = new TextField("descr");
> >>                 TextField amount = new TextField("amount");
> >>                 DropDownChoice type = new DropDownChoice("type", 
> >> Arrays.asList(new 
> >> String[]{"Registration","Documentation","Others","TaxItems"}));
> >>                 RadioChoice taxable = new RadioChoice("taxable");
> >>                 CheckBox capitalized = new CheckBox("capitalized");
> >>
> >>                 Button submitButton = new AjaxButton("submitButton"){
> >>                         @Override
> >>                         protected void onSubmit(AjaxRequestTarget target, 
> >> Form form) {
> >>                                 logger.debug("Ajax success: form: ",form);
> >>                                 logger.debug("model object 
> >> is"+form.getModelObject());
> >>                                 getFeesList().add(form.getModelObject());
> >>                                 target.addComponent(feesContainer);
> >>                         }
> >>                         @Override
> >>                         protected void onError(AjaxRequestTarget target, 
> >> Form form) {
> >>                                 logger.debug("in ajax error msg");
> >>                                 super.onError(target, form);
> >>                         }
> >>                 };
> >>                 form.add(descr);
> >>                 form.add(amount);
> >>                 form.add(type);
> >>                 form.add(taxable);
> >>                 form.add(capitalized);
> >>                 form.add(submitButton);
> >>
> >>                 feesContainer = new WebMarkupContainer("feesContainer");
> >>                 feesContainer.setOutputMarkupId(true);
> >>                 feesContainer.add(fees);
> >>                 add(feesContainer);
> >>
> >>                 add(new Label("pageTitle", pageTitle));
> >>         }
> >>
> >>         private List feesList = new ArrayList();
> >>
> >>         public List getFeesList() {
> >>                 return feesList;
> >>         }
> >>
> >>         public void setFeesList(List feesList) {
> >>                 this.feesList = feesList;
> >>         }
> >>
> >> }
> >>
> >> FeeForm.java
> >>
> >> public class FeeForm extends Form{
> >>     private static final Logger log = 
> >> LoggerFactory.getLogger(FeeForm.class);
> >>     private static final long serialVersionUID = 1L;
> >>     public FeeForm(String id, IModel model) {
> >>         super(id,model);
> >>     }
> >> }
> >>
> >> FeeModel.java
> >>
> >> public class FeeModel implements Serializable{
> >>         private String descr;
> >>         private double amount;
> >>         private String type ;
> >>         private String taxable ;
> >>         private String capitalized ;;
> >>         // and getters and setters
> >> }
> >>
> >>
> >>
> >> Fee.html
> >>
> >>
> >>
> >>
> >>
> >>
> >> Description:
> >> Amount:
> >> Type:
> >> Taxable: Yes No
> >> Capitalized:
> >> submit
> >>
> >>
> >> Current Fees are:
> >> #       Description     Type    Capitalized     Taxable         Amount
> >> [3222]  [Registration Fee]      [Documentation]         [No]    [Yes]   
> >> [$200.44]
> >>
> >> Can anyone help me out?
> >>
> >> Any pointers would be appriciated
> >>
> >> --
> >> Cheers,
> >> VJ
> >>
> >>
> >
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
>
>
> --
> Cheers,
> VJ
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to