Ok, So I have a repeater that repeats different fragments many times. One
of the fragments has a "sub-fragment".
On another note, a fragment may not be the best solution to my problem.
Essentially I want to be able to show/hide a piece of HTML depending on a
previous form selection.
ie. in a drop down, when it changes, add a list that has the associated
values. if a selection is chosen that has no associated values, hide the
list.
Here is my code so far attempting to use a fragment:
JAVA:
outerFragment = new Fragment(paletteRepeater.newChildId()
,"fragment",form);
throttleMemFragment.add(getPalette());
throttleMemFragment.setOutputMarkupId(true);
paletteRepeater.addOrReplace(throttleMemFragment);
sampleTypeSelect = new ListMultipleChoice<String>("sampleTypeSelect",new
ArrayList());
OnChangeAjaxBehavior metricDropDownBehavior = new
OnChangeAjaxBehavior(){
protected void onUpdate(AjaxRequestTarget
target){
String selection =
metricDropDown.getDefaultModelObjectAsString();
List metrics =
(List)menuMap.get(selection);
metricSelect.setChoices(metrics);
Fragment innerFragment= new
Fragment("outerFragment","innerFragment",form);
sampleTypeFragment.add(sampleTypeSelect);
if(sampleTypeMap.containsKey(selection)){
sampleTypeSelect.setChoices((List)sampleTypeMap.get(selection));
outerFragment.add(sampleTypeFragment);
sampleTypeSelect.setRequired(true);
}
else
if(outerFragment.contains(sampleTypeSelect, true)){
outerFragment.remove(sampleTypeFragment);
sampleTypeSelect.setRequired(false);
}
target.addComponent(paletteRepeater.getParent());
}
};
HTML:
<wicket:fragment wicket:id="outerFragment">
<div id="dateTimeDiv">
<table width="470px">
<tr>
<td><b>Metric:</b></td>
<td colspan="4"><select wicket:id="metricSelect" size="5"
multiple="true"></select></td>
</tr>
</table>
</div>
</wicket:fragment>
<wicket:fragment wicket:id="innerFragment">
<tr>
<td><b>Sample Type:</b></td>
<td colspan="4"><select
wicket:id="sampleTypeSelect"></select></td>
</tr>
</wicket:fragment>
<div wicket:id="paletteRepeater">
</div>
Original Message:
-----------------
From: Igor Vaynberg [email protected]
Date: Fri, 26 Feb 2010 08:42:34 -0800
To: [email protected]
Subject: Re: nested fragments?
On Fri, Feb 26, 2010 at 8:12 AM, [email protected]
<[email protected]> wrote:
> is it possible to have nested fragments?
>
> does anyone have a code snippet they can share?
maybe you can share more of your code
-igor
>when i try to add the new
> fragment to the existing fragment i get an error stating:
>
> WicketMessage: The component(s) below failed to render. A common problem
is
> that you have added a component in code but forgot to reference it in the
> markup (thus the component will never be rendered).
>
> 1. [MarkupContainer [Component id = outerFragment]]
> 2. [MarkupContainer [Component id = innerFragment]]
>
> Root cause:
>
> org.apache.wicket.WicketRuntimeException: The component(s) below failed to
> render. A common problem is that you have added a component in code but
> forgot to reference it in the markup (thus the component will never be
> rendered).
>
> 1. [MarkupContainer [Component id = outerFragment]]
> 2. [MarkupContainer [Component id = innerFragment]]
>
> at org.apache.wicket.Page.checkRendering(Page.java:1162)
> at org.apache.wicket.Page.endComponentRender(Page.java:430)
> at
>
org.apache.wicket.ajax.AjaxRequestTarget.respondComponent(AjaxRequestTarget.
> java:836)
> at
>
org.apache.wicket.ajax.AjaxRequestTarget.respondComponents(AjaxRequestTarget
> .java:680)
> at
>
org.apache.wicket.ajax.AjaxRequestTarget.respond(AjaxRequestTarget.java:590)
>
> ...
>
> --------------------------------------------------------------------
> mail2web.com What can On Demand Business Solutions do for you?
> http://link.mail2web.com/Business/SharePoint
>
>
>
> ---------------------------------------------------------------------
> 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]
--------------------------------------------------------------------
mail2web.com Enhanced email for the mobile individual based on Microsoft®
Exchange - http://link.mail2web.com/Personal/EnhancedEmail
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]