You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dukehoops <ni...@doppelganger.com> on 2008/10/03 21:43:36 UTC

Custom Radio component with children?

I'd like to create a component that consists of:
-radio
-dropdown choice

The component would be part of a RadioGroup, drop down should only be
enabled when radio is selected. The component, radio, and dropdown's
getModelObject() would return same MyBean pojo (Dropdown's is displaying a
list of MyPojos) - because that model would be used by owning RadioGroup

What model class should I use?

Also what should the component type be? Should this component be a:
-panel
-FromComponentPanel
-or subclass of Radio?

Radio is a MarkupContainer which means I should be able to extend Radio and
add DropDownChoice as a child. However, radio's markup is [input/] which
AFAIK does not allow children. So, if the answer to above is "subclass
Radio" what to do with HTML?

thanks
-nikita

-----
----------------
Nikita Tovstoles
vside.com
----------------

-- 
View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19804341.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by Igor Vaynberg <ig...@gmail.com>.
we do not guarantee the order of updates for sibling components, we
only guarantee that the deepest components are visited first - so you
should not make an assumption about order of evaluation when writing
the code.

it is indeed weird that the FCP is not visited, as far as i can see
the visisitor visits all formcomponents of which FCP is a subclass.

-igor

On Tue, Oct 7, 2008 at 11:19 AM, dukehoops <ni...@doppelganger.com> wrote:
>
> I have run the page in Tomcat and narrowed down the problem to the following:
> - FCP's convertInput is NOT called only when radio tied to drop down is
> selected.
>
> I think the problem has something to do with both PublicLocationRadio and
> PublicLocationDropDownChoice sharing the same model (publicLocationModel).
> Here's what is happening (in actual order) during form submit:
> -FormComponent.convertInput() called on Radio Group. at end of method
> 'convertedInput' is null (THIS IS BECAUSE SELECTED PublicLocationRadio's
> model object is null)
> -FormComponent.convertInput() called on PublicLocationDropDown. convertInput
> is corrrectly updated to new PublicEventLocation model object
> -FromComponent.convertInput() is NOT called at all. As the matter of fact,
> FCP is NOT visited with ValidationVisitor created inside
> Form.validateComponents()
>
>
> So, I clearly made a wrong assumption that DropDownChoice would be evaluated
> before PublicLocationRadio. I thought dropdown would update
> publicLocationModel to own selected value and when RadioGroup's convertValue
> calls publicLocationradio.getModelObject(), publicLocationModel would return
> newly updated model object.
>
> But I still do not understand why FCP's is not visited in
> Form.validateComponents() or its' convertInput method called.
>
> my RadioGroup is setRequired(true) and yet, because of the above problem,
> its' convertInput is set to null. Would that be the reason why FCP is not
> visited?
>
> thanks,
>
>
> -----
> ----------------
> Nikita Tovstoles
> vside.com
> ----------------
>
> --
> View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19864220.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by dukehoops <ni...@doppelganger.com>.
I have run the page in Tomcat and narrowed down the problem to the following:
- FCP's convertInput is NOT called only when radio tied to drop down is
selected. 

I think the problem has something to do with both PublicLocationRadio and
PublicLocationDropDownChoice sharing the same model (publicLocationModel).
Here's what is happening (in actual order) during form submit:
-FormComponent.convertInput() called on Radio Group. at end of method
'convertedInput' is null (THIS IS BECAUSE SELECTED PublicLocationRadio's
model object is null)
-FormComponent.convertInput() called on PublicLocationDropDown. convertInput
is corrrectly updated to new PublicEventLocation model object
-FromComponent.convertInput() is NOT called at all. As the matter of fact,
FCP is NOT visited with ValidationVisitor created inside
Form.validateComponents()


So, I clearly made a wrong assumption that DropDownChoice would be evaluated
before PublicLocationRadio. I thought dropdown would update
publicLocationModel to own selected value and when RadioGroup's convertValue
calls publicLocationradio.getModelObject(), publicLocationModel would return
newly updated model object.

But I still do not understand why FCP's is not visited in
Form.validateComponents() or its' convertInput method called.

my RadioGroup is setRequired(true) and yet, because of the above problem,
its' convertInput is set to null. Would that be the reason why FCP is not
visited?

thanks,


-----
----------------
Nikita Tovstoles
vside.com
----------------

-- 
View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19864220.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by dukehoops <ni...@doppelganger.com>.
It is not easy for me to check whether this component functions outside of
test harness at the moment (dependency issues) but I will do so tomorrow.

In the mean time, debugging the unit test further I can tell that:
radioGroup and DropDownChoices are the only components that get called by
validate(FormComponent) method inside Form.validateComponents().
LocationSelectionPanel does not (even though all three are children of form)


BTW, FormComponentPanel overrides checkRequired() but - contrary to javadocs
on checkRequired() - does NOT call isRequired() first. Unsure what that
means though...

-nikita


igor.vaynberg wrote:
> 
> does this work without wickettester?
> 

-----
----------------
Nikita Tovstoles
vside.com
----------------

-- 
View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19849085.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by Igor Vaynberg <ig...@gmail.com>.
does this work without wickettester?

-igor

On Mon, Oct 6, 2008 at 2:24 PM, dukehoops <ni...@doppelganger.com> wrote:
>
> Sure, here it is below. Test selects a non-default value from
> 'publicLocationChoices' drop down. Problems are:
> -on form submit, LocationSelectionPanel.convertInput() is not called (have
> breakpoint there)
> -in debugger, I can see dropDown's rawInput changing on form submit, but
> model's object ('data') value is never updated
>
> Test
>    public void testLocationSelectionPanel_SelectCohost() {
>        final WicketTester t = getTester();
>        final VirtualEventFormBean formBean = new VirtualEventFormBean();
>        formBean.setEventId(EVENT_ID);
>        formBean.setOrganizerId(currentUser.getId());
>        final EventLocation initialLocation =
> virtualEventService.getCustomSpaceEventLocation(currentUser.getId());
>        formBean.setLocation(initialLocation);
>
>        LocationSelectionPanelTestPage p = new
> LocationSelectionPanelTestPage(formBean);
>        t.startPage(p);
>        t.assertRenderedPage(LocationSelectionPanelTestPage.class);
>
>        DropDownChoice publicLocationsChoice = (DropDownChoice)
> t.getComponentFromLastRenderedPage("form:location:publicLocationChoices");
> //selecting component
>
>        FormTester ft = t.newFormTester("form");
>
>        //select cohost
>        ft.select("location:publicLocationChoices", 1); //select 1st public
> location
>
>        //submit
>        ft.submit();
>        EventLocation newLocation = p.getFormBean().getLocation();
>        assertNotSame(initialLocation, newLocation);
>        assertTrue(newLocation instanceof PublicEventLocation);
>    }
>
> Test Page
> public class LocationSelectionPanelTestPage extends AbstractWebPage {
>
>    @SpringBean private VirtualEventService virtualEventService;
>
>    private final VirtualEventFormBean formBean;
>    private CompoundPropertyModel model;
>
>    public LocationSelectionPanelTestPage(VirtualEventFormBean formBean) {
>        assert formBean != null;
>        this.formBean = formBean;
>        model = new CompoundPropertyModel(formBean);
>        Form form = new Form("form", model);
>        add(form);
>
>        //location selection
>        final CustomSpaceEventLocation organizerLocation =
> virtualEventService.getCustomSpaceEventLocation(formBean.getOrganizerId());
>        //assemble cohost models
>        List<CustomSpaceEventLocation> cohostLocations = new
> ArrayList<CustomSpaceEventLocation>();
>        for (Serializable cohostId : formBean.getCohosts()) {
>            CustomSpaceEventLocation cohostLocation =
> virtualEventService.getCustomSpaceEventLocation(cohostId);
>            cohostLocations.add(cohostLocation);
>        }
>
>        LocationSelectionPanel locationSelectionPanel = new
> LocationSelectionPanel(
>                "location",
>                organizerLocation,
>                cohostLocations,
>                virtualEventService.getPublicEventLocations(),
>                formBean);
>
>        form.add(locationSelectionPanel);
>    }
>
>    public VirtualEventFormBean getFormBean() {
>        return formBean;
>    }
> }
>
> Custom Component In Question
> public class LocationSelectionPanel extends FormComponentPanel {
>
>    //final private PublicLocationRadio publicLocationRadio;
>    final private RadioGroup locationGroup;
>    final private PublicLocationDropDownChoice publicLocationDropDown;
>    final private VirtualEventFormBean formBean;
>    //final private BoundCompoundPropertyModel model;
>    //final static String LOCATION_PROPERTY = "location";
>    final private Model publicLocationModel = new Model();
>    final private Model locationGroupModel = new Model();
>    final private CustomSpaceEventLocation organizerLocation;
>
>    public LocationSelectionPanel(
>            String wicketId,
>            CustomSpaceEventLocation organizerLocation,
>            List<CustomSpaceEventLocation> cohostLocations,
>            List<PublicEventLocation> publicLocations,
>            VirtualEventFormBean formBean) {
>
>        super(wicketId);
>        assert organizerLocation != null;
>        assert cohostLocations != null;
>        assert publicLocations != null;
>        assert formBean != null;
>
>        this.formBean = formBean;
>        this.organizerLocation = organizerLocation;
>
>        this.setRequired(true);
>
>        //model = new BoundCompoundPropertyModel(formBean);
>        this.setModel(new Model(formBean.getLocation()));
>        //model.bind(this, LOCATION_PROPERTY);
>
>
>        //group will default to location specified in formBean.location
>        locationGroup = new RadioGroup("locationGroup", locationGroupModel);
>        locationGroup.setRequired(true);
>        add(locationGroup); //bind RadioGroup's model object to location
> property of this.model's formBean
>
>        // organizer's apt
>        CustomSpaceRadio organizerRadio = new
> CustomSpaceRadio("organizerLocation", organizerLocation);
>        locationGroup.add(organizerRadio);
>
>        //co-hosts' places
>        //create radio controls for cohosts' locations
>        ListView participantChoices = new
> CohostLocationListView("cohostLocationChoices", cohostLocations);
>        locationGroup.add(participantChoices);
>
>        //drop down for public locations
>        publicLocationDropDown = new
> PublicLocationDropDownChoice("publicLocationChoices", publicLocations);
>        add(publicLocationDropDown);
>
>        // radio for selecting public location
>        PublicLocationRadio publicLocationRadio = new
> PublicLocationRadio("publicLocation");
>        locationGroup.add(publicLocationRadio);
>    }
>
>    @Override
>    protected void onBeforeRender() {
>
>        //set child model's based on location property
>        final Object modelObject = getModelObject();
>
>        EventLocation location = (EventLocation) modelObject;
>        assert location != null;
>
>        if (location instanceof CustomSpaceEventLocation) {
>            locationGroupModel.setObject(location);
>            publicLocationModel.setObject(null);
>        } else if (location instanceof PublicEventLocation) {
>            publicLocationModel.setObject(location);
>            locationGroupModel.setObject(location);
>        } else {
>            throw new IllegalStateException("location property of unknown
> type: " + location);
>        }
>
>        //enable drop-down only if public location radio is selected
>        //publicLocationDropDown.setEnabled(location instanceof
> PublicEventLocation);
>
>        //render children
>        super.onBeforeRender();
>    }
>
>
>
>
>    /**
>     * check whether publicLocationRadio is selected. if so,
> setConvertedInput
>     * to publicLocationDropDown's model object, else to radioGroup's
>     */
>    @Override
>    protected void convertInput() {
>
>        Object convertedInput = null;
>
>        EventLocation locGroupModelObject = (EventLocation)
> locationGroup.getConvertedInput();
>        assert locGroupModelObject != null;
>
>        if (locGroupModelObject instanceof CustomSpaceEventLocation) {
>            //TODO always true because locationGroup's model is never null
>            convertedInput = locationGroup.getConvertedInput();
>        } else {
>            convertedInput =
> publicLocationDropDown.getConvertedInput();//publicLocationModel.getObject();
>        }
>
>        setConvertedInput(convertedInput);
>    }
>
>    private class PublicLocationDropDownChoice extends DropDownChoice {
>
>        public PublicLocationDropDownChoice(String wicketId,
> List<PublicEventLocation> publicLocations) {
>            super(wicketId, publicLocationModel, publicLocations, new
> PublicEventLocationChoiceRenderer());
>        }
>    }
>
>    private class PublicLocationRadio extends Radio {
>
>        public PublicLocationRadio(String wicketId) {
>            super(wicketId);
>            setModel(publicLocationModel);
>        }
>    }
>
>    private class PublicEventLocationChoiceRenderer implements
> IChoiceRenderer {
>
>        public Object getDisplayValue(Object object) {
>            if (object instanceof PublicEventLocation) {
>                return ((PublicEventLocation) object).getName();
>            }
>            return null;
>        }
>
>        public String getIdValue(Object object, int index) {
>            return String.valueOf(index);
>        }
>    }
>
>    private class CohostLocationListView extends ListView {
>
>        public CohostLocationListView(String wicketId,
> List<CustomSpaceEventLocation> cohostLocations) {
>            super(wicketId, cohostLocations);
>        }
>
>        protected void populateItem(ListItem item) {
>            item.add(new CustomSpaceRadio("cohostLocation",
> (CustomSpaceEventLocation) item.getModelObject()));
>        }
>    }
> }
>
>
>
> -----
> ----------------
> Nikita Tovstoles
> vside.com
> ----------------
>
> --
> View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19846733.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by dukehoops <ni...@doppelganger.com>.
Sure, here it is below. Test selects a non-default value from
'publicLocationChoices' drop down. Problems are:
-on form submit, LocationSelectionPanel.convertInput() is not called (have
breakpoint there)
-in debugger, I can see dropDown's rawInput changing on form submit, but
model's object ('data') value is never updated

Test
    public void testLocationSelectionPanel_SelectCohost() {
        final WicketTester t = getTester();
        final VirtualEventFormBean formBean = new VirtualEventFormBean();
        formBean.setEventId(EVENT_ID);
        formBean.setOrganizerId(currentUser.getId());
        final EventLocation initialLocation =
virtualEventService.getCustomSpaceEventLocation(currentUser.getId());
        formBean.setLocation(initialLocation);

        LocationSelectionPanelTestPage p = new
LocationSelectionPanelTestPage(formBean);
        t.startPage(p);
        t.assertRenderedPage(LocationSelectionPanelTestPage.class);

        DropDownChoice publicLocationsChoice = (DropDownChoice)
t.getComponentFromLastRenderedPage("form:location:publicLocationChoices");
//selecting component

        FormTester ft = t.newFormTester("form");

        //select cohost        
        ft.select("location:publicLocationChoices", 1); //select 1st public
location

        //submit 
        ft.submit();
        EventLocation newLocation = p.getFormBean().getLocation();
        assertNotSame(initialLocation, newLocation);
        assertTrue(newLocation instanceof PublicEventLocation);
    }

Test Page
public class LocationSelectionPanelTestPage extends AbstractWebPage {

    @SpringBean private VirtualEventService virtualEventService;
    
    private final VirtualEventFormBean formBean;
    private CompoundPropertyModel model;

    public LocationSelectionPanelTestPage(VirtualEventFormBean formBean) {
        assert formBean != null;
        this.formBean = formBean;
        model = new CompoundPropertyModel(formBean);
        Form form = new Form("form", model);
        add(form);

        //location selection
        final CustomSpaceEventLocation organizerLocation =
virtualEventService.getCustomSpaceEventLocation(formBean.getOrganizerId());
        //assemble cohost models
        List<CustomSpaceEventLocation> cohostLocations = new
ArrayList<CustomSpaceEventLocation>();
        for (Serializable cohostId : formBean.getCohosts()) {
            CustomSpaceEventLocation cohostLocation =
virtualEventService.getCustomSpaceEventLocation(cohostId);
            cohostLocations.add(cohostLocation);
        }

        LocationSelectionPanel locationSelectionPanel = new
LocationSelectionPanel(
                "location",
                organizerLocation,
                cohostLocations,
                virtualEventService.getPublicEventLocations(),
                formBean);
        
        form.add(locationSelectionPanel);
    }

    public VirtualEventFormBean getFormBean() {
        return formBean;
    }
}

Custom Component In Question
public class LocationSelectionPanel extends FormComponentPanel {

    //final private PublicLocationRadio publicLocationRadio;
    final private RadioGroup locationGroup;
    final private PublicLocationDropDownChoice publicLocationDropDown;
    final private VirtualEventFormBean formBean;
    //final private BoundCompoundPropertyModel model;
    //final static String LOCATION_PROPERTY = "location";
    final private Model publicLocationModel = new Model();
    final private Model locationGroupModel = new Model();
    final private CustomSpaceEventLocation organizerLocation;

    public LocationSelectionPanel(
            String wicketId,
            CustomSpaceEventLocation organizerLocation,
            List<CustomSpaceEventLocation> cohostLocations,
            List<PublicEventLocation> publicLocations,
            VirtualEventFormBean formBean) {

        super(wicketId);
        assert organizerLocation != null;
        assert cohostLocations != null;
        assert publicLocations != null;
        assert formBean != null;

        this.formBean = formBean;
        this.organizerLocation = organizerLocation;
        
        this.setRequired(true);

        //model = new BoundCompoundPropertyModel(formBean);
        this.setModel(new Model(formBean.getLocation()));
        //model.bind(this, LOCATION_PROPERTY);
        

        //group will default to location specified in formBean.location
        locationGroup = new RadioGroup("locationGroup", locationGroupModel);
        locationGroup.setRequired(true);
        add(locationGroup); //bind RadioGroup's model object to location
property of this.model's formBean

        // organizer's apt
        CustomSpaceRadio organizerRadio = new
CustomSpaceRadio("organizerLocation", organizerLocation);
        locationGroup.add(organizerRadio);

        //co-hosts' places        
        //create radio controls for cohosts' locations
        ListView participantChoices = new
CohostLocationListView("cohostLocationChoices", cohostLocations);
        locationGroup.add(participantChoices);

        //drop down for public locations
        publicLocationDropDown = new
PublicLocationDropDownChoice("publicLocationChoices", publicLocations);
        add(publicLocationDropDown);

        // radio for selecting public location
        PublicLocationRadio publicLocationRadio = new
PublicLocationRadio("publicLocation");
        locationGroup.add(publicLocationRadio);
    }

    @Override
    protected void onBeforeRender() {

        //set child model's based on location property        
        final Object modelObject = getModelObject();

        EventLocation location = (EventLocation) modelObject;
        assert location != null;

        if (location instanceof CustomSpaceEventLocation) {
            locationGroupModel.setObject(location);
            publicLocationModel.setObject(null);
        } else if (location instanceof PublicEventLocation) {
            publicLocationModel.setObject(location);
            locationGroupModel.setObject(location);
        } else {
            throw new IllegalStateException("location property of unknown
type: " + location);
        }

        //enable drop-down only if public location radio is selected
        //publicLocationDropDown.setEnabled(location instanceof
PublicEventLocation);

        //render children
        super.onBeforeRender();
    }
    
    
    

    /**
     * check whether publicLocationRadio is selected. if so,
setConvertedInput 
     * to publicLocationDropDown's model object, else to radioGroup's
     */
    @Override
    protected void convertInput() {

        Object convertedInput = null;
        
        EventLocation locGroupModelObject = (EventLocation)
locationGroup.getConvertedInput();        
        assert locGroupModelObject != null;

        if (locGroupModelObject instanceof CustomSpaceEventLocation) {
            //TODO always true because locationGroup's model is never null
            convertedInput = locationGroup.getConvertedInput();
        } else {
            convertedInput =
publicLocationDropDown.getConvertedInput();//publicLocationModel.getObject();
        }

        setConvertedInput(convertedInput); 
    }

    private class PublicLocationDropDownChoice extends DropDownChoice {

        public PublicLocationDropDownChoice(String wicketId,
List<PublicEventLocation> publicLocations) {
            super(wicketId, publicLocationModel, publicLocations, new
PublicEventLocationChoiceRenderer());
        }
    }

    private class PublicLocationRadio extends Radio {

        public PublicLocationRadio(String wicketId) {
            super(wicketId);
            setModel(publicLocationModel);
        }
    }

    private class PublicEventLocationChoiceRenderer implements
IChoiceRenderer {

        public Object getDisplayValue(Object object) {
            if (object instanceof PublicEventLocation) {
                return ((PublicEventLocation) object).getName();
            }
            return null;
        }

        public String getIdValue(Object object, int index) {
            return String.valueOf(index);
        }
    }

    private class CohostLocationListView extends ListView {

        public CohostLocationListView(String wicketId,
List<CustomSpaceEventLocation> cohostLocations) {
            super(wicketId, cohostLocations);
        }

        protected void populateItem(ListItem item) {
            item.add(new CustomSpaceRadio("cohostLocation",
(CustomSpaceEventLocation) item.getModelObject()));
        }
    }
}



-----
----------------
Nikita Tovstoles
vside.com
----------------

-- 
View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19846733.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by Igor Vaynberg <ig...@gmail.com>.
paste some code

-igor

On Mon, Oct 6, 2008 at 12:35 PM, dukehoops <ni...@doppelganger.com> wrote:
>
> I made my component a subclass of FormComponentPanel and overrode
> convertInput(). However when form containing this formComponentPanel is
> submitted, panel's convertInput method is never called.
>
> As result panel displays correctly, but changes are lost on submission. Any
> ideas?
>
> -----
> ----------------
> Nikita Tovstoles
> vside.com
> ----------------
>
> --
> View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19844805.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by dukehoops <ni...@doppelganger.com>.
I made my component a subclass of FormComponentPanel and overrode
convertInput(). However when form containing this formComponentPanel is
submitted, panel's convertInput method is never called. 

As result panel displays correctly, but changes are lost on submission. Any
ideas?

-----
----------------
Nikita Tovstoles
vside.com
----------------

-- 
View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19844805.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by Igor Vaynberg <ig...@gmail.com>.
correct

-igor

On Fri, Oct 3, 2008 at 3:00 PM, dukehoops <ni...@doppelganger.com> wrote:
>
> You mean "check the convertedinput() of radiogroup" not radio, correct?
>
>
> igor.vaynberg wrote:
>>
>> the easiest way to do this would be to make your component a
>> formcomponentpanel
>>
>> then you have
>>
>> formcomponentpanel
>> -radiogroup
>> --radio1
>> --radio2
>> -dropdown
>>
>> and in your fcp's convertinput() check the convertedinput() of radio
>> and based on that call setconvertedinput() with either the radio's or
>> the dropdown's value
>>
>> -igor
>>
>
> -----
> ----------------
> Nikita Tovstoles
> vside.com
> ----------------
>
> --
> View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19806392.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by dukehoops <ni...@doppelganger.com>.
You mean "check the convertedinput() of radiogroup" not radio, correct?
 

igor.vaynberg wrote:
> 
> the easiest way to do this would be to make your component a
> formcomponentpanel
> 
> then you have
> 
> formcomponentpanel
> -radiogroup
> --radio1
> --radio2
> -dropdown
> 
> and in your fcp's convertinput() check the convertedinput() of radio
> and based on that call setconvertedinput() with either the radio's or
> the dropdown's value
> 
> -igor
> 

-----
----------------
Nikita Tovstoles
vside.com
----------------

-- 
View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19806392.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Custom Radio component with children?

Posted by Igor Vaynberg <ig...@gmail.com>.
the easiest way to do this would be to make your component a formcomponentpanel

then you have

formcomponentpanel
-radiogroup
--radio1
--radio2
-dropdown

and in your fcp's convertinput() check the convertedinput() of radio
and based on that call setconvertedinput() with either the radio's or
the dropdown's value

-igor

On Fri, Oct 3, 2008 at 12:43 PM, dukehoops <ni...@doppelganger.com> wrote:
>
> I'd like to create a component that consists of:
> -radio
> -dropdown choice
>
> The component would be part of a RadioGroup, drop down should only be
> enabled when radio is selected. The component, radio, and dropdown's
> getModelObject() would return same MyBean pojo (Dropdown's is displaying a
> list of MyPojos) - because that model would be used by owning RadioGroup
>
> What model class should I use?
>
> Also what should the component type be? Should this component be a:
> -panel
> -FromComponentPanel
> -or subclass of Radio?
>
> Radio is a MarkupContainer which means I should be able to extend Radio and
> add DropDownChoice as a child. However, radio's markup is [input/] which
> AFAIK does not allow children. So, if the answer to above is "subclass
> Radio" what to do with HTML?
>
> thanks
> -nikita
>
> -----
> ----------------
> Nikita Tovstoles
> vside.com
> ----------------
>
> --
> View this message in context: http://www.nabble.com/Custom-Radio-component-with-children--tp19804341p19804341.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org