See http://wicketinaction.com/2011/11/implement-wicket-component-visibility-changes-properly/
On Thu, Mar 28, 2013 at 3:36 PM, Patrick Davids <[email protected]>wrote: > I am not sure what exactly was wrong. > Perhaps I had too much code with several active setVisibility...() XYZs > code parts. > > I started from the beginning and found the beautiest way for me, looking > like this. > > final RadioChoice<String> r = new RadioChoice<String>("id", > Model.of(""), Arrays.asList(new String[{"visible","invisible"})); > > r.setModelObject("visible"); > > final WebMarkupContainer wmc = new WebMarkupContainer("wmc"){ > @Override > protected void onConfigure() { > if(r.getValue().equals("0")){ > setVisibilityAllowed(true); > } > if(r.getValue().equals("1")){ > setVisibilityAllowed(false); > } > } > wmc.setOutputMarkupPlaceholderTag(true); > > r.add(new AjaxFormChoiceComponentUpdatingBehavior(){ > @Override > protected void onUpdate(AjaxRequestTarget target) { > target.add(wmc); > } > } > ); > > > ================ > onConfigure() is always be executed, and can toggle the visibility. > > AjaxFormChoiceComponentUpdatingBehavior.onUpdate() just pushes back the > wmc, and due to onConfigure() of the wmc it determines its visibility > depending on the new state of RadioCoice r. > > kind regards > Patrick > > > Am 28.03.2013 13:44, schrieb Martin Grigorov: > > Hi, > > > > All you have explained should just work. > > It seems the component is still invisible after setVisible(true). Maybe > you > > override it later ?! As you said in #onConfigure() or #isVisible() > returns > > false ? > > Please show some code. > > > > > > On Thu, Mar 28, 2013 at 12:30 PM, Patrick Davids > > <[email protected]>wrote: > > > >> Additional info: > >> > >> Its now working partially... > >> > >> I removed the onConfigure() of the markup container to determine the > >> initial visibility of itself depending on the radio default choice. > >> > >> So, my question changes to: > >> Whats the best way todo such an initial visibility without affecting the > >> ajax visibility changing? > >> > >> Patrick > >> > >> > >> Am 28.03.2013 11:18, schrieb Sven Meier: > >>>> My behavior on the gui is: > >>>> - the first render process of the page itself shows the container once > >>>> - on clicking my radiochoice the webmarkupcontainer disappears but is > >>>> still available, due to outPutMarkUpPlaceHolder true, but the content > is > >>>> completly removed and the visibility of the container is always > >>>> display:none. > >>>> > >>>> Using setVisible or using setVisibilityAllowed does not make any > >> changes. > >>> > >>> So your container disappears but does not show up again after setting > it > >>> visible? > >>> > >>> Sven > >>> > >>> On 03/28/2013 11:12 AM, Patrick Davids wrote: > >>>> Hi together, > >>>> I searched the web for several hours and always get the same results > for > >>>> setting the visibilty for components via ajax, but I cannot get it > work. > >>>> > >>>> The "should work" solution is: > >>>> - Creat an extra a WebMarkupContainer in your page > >>>> - add your subcomponents to this container > >>>> - setOutPutMarkUpIdPlacerHolderTag(true) for the container > >>>> - implement ajax anywhere (in my case its an > >>>> AjaxFormChoiceComponentUpdatingBehavior) > >>>> - override its onUpdate and setVisibilty of the container true or > false > >>>> depending on something > >>>> - do target.add( the webmarkupcontainer ) > >>>> > >>>> Tada... but nothing happens. > >>>> > >>>> My problems are: > >>>> All solutions I found are about 2-5 years old, so: > >>>> - the usage of setVisibilty has changed (setVisible vs. > >>>> setVisibilityAllowed() discussion) > >>>> - target does not have an addComponent() method anymore (but this is > >>>> easy, should be add(...)) > >>>> - perhaps the hole "SetVisibilityViaAjax"-way has changed since newer > >>>> wicket versions? > >>>> > >>>> My behavior on the gui is: > >>>> - the first render process of the page itself shows the container once > >>>> - on clicking my radiochoice the webmarkupcontainer disappears but is > >>>> still available, due to outPutMarkUpPlaceHolder true, but the content > is > >>>> completly removed and the visibility of the container is always > >>>> display:none. > >>>> > >>>> Using setVisible or using setVisibilityAllowed does not make any > >> changes. > >>>> > >>>> Whats wrong?!? :-( > >>>> > >>>> (using wicket 6.6) > >>>> > >>>> kind regards > >>>> Patrick > >>>> --------------------------------------------------------------------- > >>>> 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] > >>> > >> > >> -- > >> Mit freundlichen Grüßen, > >> > >> Patrick Davids > >> > >> NuboIT GmbH & Co. KG > >> Kieler Str. 103-107 • 25474 Bönningstedt > >> > >> Email: [email protected] > >> > >> Handelsregister: HRA6819 Pi | Amtsgericht Pinneberg > >> > >> Geschäftsführung der Verwaltungsgesellschaft > >> Daniel Fraga Zander > >> > >> HRB10145Pi | Amtsgericht Pinneberg > > > > > > > > > > -- > Mit freundlichen Grüßen, > > Patrick Davids > > NuboIT GmbH & Co. KG > Kieler Str. 103-107 • 25474 Bönningstedt > > Email: [email protected] > > Handelsregister: HRA6819 Pi | Amtsgericht Pinneberg > > Geschäftsführung der Verwaltungsgesellschaft > Daniel Fraga Zander > > HRB10145Pi | Amtsgericht Pinneberg > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com <http://jweekend.com/>
