Hi,

here is a (for me) working code snipplet populated from the example given by
Igor:

<snip>

/** SelectedFields may be pojo or so */

/* data */
Selected Fields[] collector;

/* list */
List<SelectedFields> dataList = Arrays.asList(collector);

/* model to save selection */
final Model<ArrayList<String>> fieldsModel;

/* ichoice renderer */
IChoiceRenderer<SelectedFields> renderer = new
ChoiceRenderer<SelectedFields>("selectedValue", "selectedValue");

/* palette */
Palette palette = new
Palette("palette",saveSelectedFields,Model.of(dataList),renderer,dataList.size(),true)
{

    /**
     *
     */
    private static final long serialVersionUID=1L;

    @Override
    protected Recorder newRecorderComponent()
    {
        Recorder c=super.newRecorderComponent();
        c.add(new AjaxFormComponentUpdatingBehavior("onchange")
        {

        /**
         *
         */
        private static final long serialVersionUID=1L;

        /* populate every change in selection to palette model */
        @Override
        protected void onUpdate(AjaxRequestTarget target)
        {

            /* init cache */
            ArrayList<String> tempList=new ArrayList<String>();

            /* foreach selected field.. */
            for(int a=0; a<saveSelectedFields.getObject().size(); a++)
            {

                /* get and save the value*/

tempList.add(saveSelectedFields.getObject().get(a).getSelectedValue());
            }

            /* if at least one is selected */
            if(tempList.size()>0)
            {

                /* save it to model */
                fieldsModel.setObject(tempList);
            }
        }
    });
    return c;
}

/* publish */
add(palette);

</snip>

Hope this helps.

Best regards
Christoph


On Wed, Mar 31, 2010 at 3:19 AM, wicketnewuser <[email protected]> wrote:

>
> Hi i tried doing this it doesn't like adding
> AjaxFormComponentUpdatingBehavior . I thought when you meant
> AjaxFormComponentUpdatingBehavior by whateverbehaviour. i even added
> onupdate method that didn't help too. still getting null when doing
> pallet.getRecorderComponent. Please help
>                new PropertyModel(model,"allSids"),
>                                renderer, 12, false){
>                               protected Recorder<LeadSid>
> newRecorderComponent() {
>                                        Recorder
> r=super.newRecorderComponent();
>                                        r.add(new
>  AjaxFormComponentUpdatingBehavior("onchange"));
>                                        return r;
>                                        }
>
>                };
>
>
> Edvin Syse wrote:
> >
> > Thanks! Will you update the javadoc as well?
> >
> > -- Edvin
> >
> > Den 28. juli. 2008 kl. 16.37 skrev "Igor Vaynberg"
> > <[email protected]
> >  >:
> >
> >> override newrecorder() { recorder r=super.newrecorder(); r.add(new
> >> whateverbehavior()); return r; }
> >>
> >> -igor
> >>
> >> On Mon, Jul 28, 2008 at 12:33 AM, Edvin Syse <[email protected]>
> >> wrote:
> >>> The javadocs for the Palette says to add
> >>> AjaxFormComponentUpdatingBehaviour
> >>> to the Recorder like this:
> >>>
> >>>       Form form=new Form(...);
> >>>       Palette palette=new Palette(...);
> >>>       palette.getRecorderComponent().add(new
> >>> AjaxFormComponentUpdatingBehavior("onchange") {...});
> >>>
> >>> getRecorderComponent() is null, because it isn't populated in the
> >>> Palette's
> >>> constructor, it is populated
> >>> in the private initFactories() method, which is called from
> >>> onBeforeRender.
> >>>
> >>> How am I supposed to get to the Recorder-component from the
> >>> constructor of
> >>> my pageclass? :)
> >>>
> >>>
> >>> -- Edvin
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [email protected]
> >>> For additional commands, e-mail: [email protected]
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/AJAXIFY-Palette%3A-Can%27t-get-to-the-Recorder-tp18685475p28090539.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to