I did not override the method. I just did and it is still not
working. Here is what I have:
Also, where would one find this type of information. I don't think the
online example show it and blindly guessing methods to look at in
javadoc doesn't seem efficient.
HTML:
<tr>
<td><wicket:message key="userType">Type of
User:</wicket:message></td>
<td>
<span wicket:id="accountType">
<input type="radio" />option 1
</span>
</td>
</tr>
<tr>
<td></td>
<td><span wicket:id="typeBox">The type
box</span></td>
</tr>
Code:
// Account Type sub box
final WebMarkupContainer typeBox = new
WebMarkupContainer("typeBox") {
/* (non-Javadoc)
* @see
org.apache.wicket.Component#callOnBeforeRenderIfNotVisible()
*/
@Override
protected boolean
callOnBeforeRenderIfNotVisible() {
return true;
}
};
typeBox.setVisible(false);
typeBox.setOutputMarkupId(true);
add(typeBox);
// Account Type Select
List accountTypes = accountTypeDao.findAll();
ChoiceRenderer accountTypeChoiceRenderer = new
ChoiceRenderer("name", "code");
RadioChoice accountTypeRadio = new
RadioChoice("accountType", accountTypes, accountTypeChoiceRenderer);
//accountTypeRadio.setRequired(true);
// add the on click to the radio button
accountTypeRadio.add(new
AjaxFormChoiceComponentUpdatingBehavior () {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
RadioChoice choice = (RadioChoice)
getComponent();
choice.updateModel();
if (((AccountType)
choice.getModelObject()).getCode().equalsIgnoreCase("REP")) {
typeBox.setVisible(true);
} else {
typeBox.setVisible(false);
}
target.addComponent(typeBox);
}
});
add(accountTypeRadio);
-----Original Message-----
From: Per Newgro [mailto:per.new...@gmx.ch]
Sent: Wednesday, September 30, 2009 2:17 AM
To: users@wicket.apache.org
Subject: Re: RadioChoice and Ajax to display a panel of dropdowns
Hey Jeff,
did you override this?
/**
* Override this method if you want onBeforeRender to be called even
when your component is not
* visible. default this returns false.
*
* @return boolean, if true then onBeforeRender is called even for
none visible components,
* default false.
*
* @see Component#onBeforeRender()
*/
protected boolean callOnBeforeRenderIfNotVisible()
{
return false;
}
If you add a visible and an invisible panel you have to override this on
the invisible one.
hth
Cheers
Per
I want to create a list of radio buttons [I have that working] and an
ajax event to fire whenever a radio button is clicked [I have this
working]. If the radio button matches the one I am interested in then
I
want to display additional information that must be filled in. A
radio
button selection is required.
I cannot get the additional information to display when I add the
component back to the target. I think it is because the additional
information is originally set to not visible so the output markup id
is
not written out. How would I go about doing this? It seems pretty
standard. Do I need to use panels and swap the appropriate panel [1 -
empty panel, 2 - panel with additional info] into the target when
needed? That seems like a lot of code to do something fairly simple.
My code is below.
Thanks.
Jeff
=====================
HTML:
<tr>
<td><wicket:message key="userType">Type of
User:</wicket:message></td>
<td>
<span wicket:id="accountType">
<input type="radio" />option 1
</span>
</td>
</tr>
<tr>
<td></td>
<td><span wicket:id="typeBox">The additional
information</span></td>
</tr>
Java Code:
// Account Type sub box
final WebMarkupContainer typeBox = new
WebMarkupContainer("typeBox");
typeBox.setVisible(false);
typeBox.setOutputMarkupId(true);
add(typeBox);
// Account Type Select
List accountTypes = accountTypeDao.findAll();
ChoiceRenderer accountTypeChoiceRenderer = new
ChoiceRenderer("name", "code");
RadioChoice accountTypeRadio = new
RadioChoice("accountType", accountTypes, accountTypeChoiceRenderer);
//accountTypeRadio.setRequired(true); // THIS
SHOULD REALLY BE REQUIRED
// add the on click to the radio button
accountTypeRadio.add(new
AjaxFormChoiceComponentUpdatingBehavior () {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
RadioChoice choice = (RadioChoice)
getComponent();
choice.updateModel();
if (((AccountType)
choice.getModelObject()).getCode().equalsIgnoreCase("REP")) {
typeBox.setVisible(true);
} else {
typeBox.setVisible(false);
}
target.addComponent(typeBox);
}
});
_______________________________________
Jeffrey A. Schneller
Envisa
End-to-End E-Commerce for the Multi-Channel Merchant
281 Pleasant Street
Framingham, MA 01701
P: (508) 405-1220 x115
C: (508) 954-8044
F: (508) 405-1219
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org