Here's the pieces that I used. Sounds like Igor's approach is better,
but here it is if you can't do it that way.
in your css:
.invisible{
display: none;
}
.visible{
display: inline;
}
Now, the component side (proficiencyChoice is a dropdown)
proficiencyChoice.setOutputMarkupId(true);
//define the model that will return the stylesheet
(visible/not visible) for the select box proficiencyChoice
IModel modelForStylesheet = new Model()
{
public Object getObject( Component c )
{
if (mdl.isSelected())
return "visible";
else
return "invisible";
}
};
proficiencyChoice.add( new AttributeModifier ( "class",
true, modelForStylesheet ));
rvitem.add(proficiencyChoice);
--James
kenixwong wrote:
> I am a wicket newbie too:)..
>
> can i know how u used CSS to control it ? can give any idea to me as well?
>
> thanks ar
>
>
>
> James Law wrote:
>
>> I am a wicket newbie, but when I had a similar thing I wanted to do, I
>> just used CSS to make the component invisible/visible (display: none).
>> The ajax behavior just changed the style. I am pretty certain setVisible
>> is not the best/easiest way to handle this.
>>
>> James
>>
>> kenixwong wrote:
>>
>>> I'd like to be able to click a set of radio box and then make a component
>>> visible or invisible using Ajax or else. Is that any idea for it?
>>>
>>> As i read the radioGroup and radioChoice, can i know what is the
>>> different
>>> btw both?
>>>
>>> Here is my partial code:
>>> categoryField = new TextField("category");
>>> categoryField.setOutputMarkupId(true);
>>>
>>> final RadioGroup radioGroup = new RadioGroup("RadioGroup", new Model());
>>> listView = new ListView("ListView", optionClassList)
>>> {
>>> protected void populateItem (final ListItem item)
>>> {
>>> Radio radio = new Radio("radio", item.getModel());
>>> radio.add (new AjaxEventBehavior("onclick")
>>> {
>>> protected void onEvent (AjaxRequestTarget target)
>>> {
>>> if(item.getModelObject ().equals("abc")){
>>> target.addComponent
>>> (departmentChoice.setVisible(false));
>>> }else{
>>> target.addComponent
>>> (categoryField.setVisible(false));
>>> }
>>> }
>>> });
>>> item.add(radio);
>>> item.add(new Label("label", (String)item.getModelObject ()));
>>> }
>>> };
>>> radioGroup.add (listView);
>>> add(radioGroup);
>>>
>>>
>>> It work, but oaly the first time. Mean after i clicked on the radio few
>>> times, it nothing happen.
>>>
>>> thanks for help...
>>>
>>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Wicket-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>
>>
>>
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user