Re: Ajax refresh component with initial setVisible(false)
Please help me out hereis there any silly mistake that I am making? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-component-with-initial-setVisible-false-tp4650171p4650205.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Ajax refresh component with initial setVisible(false)
This is my submitCommentPanel: public SubmitCommentPanel(String id, final PostDomain postDomain, final UserDomain userDomain) { super(id); this.setOutputMarkupId(true); AjaxFallbackButton ajaxCommentSubmitButton = new AjaxFallbackButton( "commentSubmitButton", commentForm) { /** * */ private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, final Form form) { /* * Populating commentDomain instance for submitting comment. * This instance is then passed to CommentService class */ if (target != null) { try { // some processing } catch (Exception exception) { error(exception.getMessage()); } target.add(submitCommentFeedbackPanel); *target.add(SubmitCommentPanel.this);* } } }; * here, I am adding one more panel which should not be visible in a situation ... ShowCommentPanel showCommentPanel = new ShowCommentPanel( "showCommentPanel", postDomain, userDomain); showCommentPanel.setVisible(!postDomain.getCommentDomainList().isEmpty()); add(showCommentPanel);* } Now ShowCommentPanel is: public ShowCommentPanel(final String id, final PostDomain postDomain, final UserDomain userDomain) { super(id); // TODO Auto-generated constructor stub * @SuppressWarnings("rawtypes") Label numberOfCommentLabel = new Label("numberOfCommentLabel", new PropertyModel(postDomain, "numberOfComments")); add(numberOfCommentLabel);* } Now what is happening that when showCommentPanel visibility is initially false but later becomes true after ajax refresh, even then *numberOfCommentLabel * does not appear. I have to refresh the whole page to make them appear. After that they refresh properly by ajax. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-component-with-initial-setVisible-false-tp4650171p4650196.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Ajax refresh component with initial setVisible(false)
Could you show us some code? This will make it much easier for us to help you, thanks! -Tom On 22.06.2012, at 04:21, kshitiz wrote: > Hi, > > I have added the whole panel in which that navigator is present. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Ajax refresh component with initial setVisible(false)
Hi, I have added the whole panel in which that navigator is present. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-component-with-initial-setVisible-false-tp4650171p4650180.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Ajax refresh component with initial setVisible(false)
Did you add your component to the AjaxRequestTarget for update? target.add(ajaxPagingNavigator); ?? Sven On 06/21/2012 06:12 PM, kshitiz wrote: Hi, How to ajax refresh components which are initially setvisible to false but later set to true. I know when it is false, then its mark up is not created in DOM. I have tried like **ajaxPagingNavigator.setOutputMarkupPlaceholderTag(true);** here, ajaxPagingNavigator is component. *But it is not appearing but its visibility becomes true.* What is the solution? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-component-with-initial-setVisible-false-tp4650171.html Sent from the Users forum mailing list archive at Nabble.com. - 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
Ajax refresh component with initial setVisible(false)
Hi, How to ajax refresh components which are initially setvisible to false but later set to true. I know when it is false, then its mark up is not created in DOM. I have tried like **ajaxPagingNavigator.setOutputMarkupPlaceholderTag(true);** here, ajaxPagingNavigator is component. *But it is not appearing but its visibility becomes true.* What is the solution? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-refresh-component-with-initial-setVisible-false-tp4650171.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Refresh component 'ajax'
How about something like AjaxSelfUpdatingTimerBehavior? Also, this page has some ajaxy examples that might help. http://www.wicket-library.com/wicket-examples/ajax/ On Wednesday, May 16, 2012 at 7:28 AM, Brown, Berlin [GCG-PFS] wrote: > I normally use 'target.addComponent(someOtherComponent)' to > refresh/rerender that HTML content. Are there other ways to > render/reload that component? > > > Also, we are using wicket version 1.4.13 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Refresh component 'ajax'
I normally use 'target.addComponent(someOtherComponent)' to refresh/rerender that HTML content. Are there other ways to render/reload that component? Also, we are using wicket version 1.4.13
Re: refresh component
do something like this ... on the markup template some text on java Label mySpan = new Label("mySpan", new AbstractReadonlyModel(){ public String getObject() { return myUpdatedText ; } }); mySpan.setOutputMarkupId(true) ; //on your ajax line updateMyText(); ajaxRequestTarget.add(mySpan); Josh. On Sat, Mar 17, 2012 at 5:15 PM, Dan12321 wrote: > Hello, > I have got span element () with text and I would like to refresh this > span when I click on ajaxlink. It is possible? How can refresh only this > span element. > The ajaxlink is not connect with this span element. These are two different > elements in page. > > Thanks. > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/refresh-component-tp4480640p4480640.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: refresh component
Hi there, you have to add the span to the AjaxRequestTarget inside your links "onClick"-method. Your span has to be a Wicket component, of course. So if your HTML looks somewhat like this: ... ... your Java has to look somewhat like this: ... Label myLabel = new Label("myspan"); // The label / span you want to refresh myLabel.setOutputMarkupId(true); Link myLink = new Link("myLink") { @Override public void onClick(AjaxRequestTarget target) { target.add(myLabel) // Add label to requestTarget to get it updated on click }); ... Hope that helps. Cheers, Andy Am 17.03.2012 15:15, schrieb Dan12321: Hello, I have got span element () with text and I would like to refresh this span when I click on ajaxlink. It is possible? How can rei tfresh only this span element. The ajaxlink is not connect with this span element. These are two different elements in page. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/refresh-component-tp4480640p4480640.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
refresh component
Hello, I have got span element () with text and I would like to refresh this span when I click on ajaxlink. It is possible? How can refresh only this span element. The ajaxlink is not connect with this span element. These are two different elements in page. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/refresh-component-tp4480640p4480640.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Ajax refresh component
Hello, Your problem is that you calling setOutputMarkupId(true) on the wrong panel (you are calling it on LawView page constructor where in fact it should be called on the component that is added to the ajax request target, LawPanel). Also I think the updated panel has to replace the current instance in the page hierarchy as well as being added to the ajax request target. Your class could benefit from using model's in a more intelligent way. Make the LawPanel detail panel work with an IModel model. Control the visibility of the details panel based on if there is a Law object present. When an ajax link is clicked just update the model value of the details panel with the selected Law object and add the existing LawPanel into the AJAX request target. This will allow your link to still work when it is just a normal link (the fallback case). For example: Assuming the details panel lawPanel is a private variable in the main class. Assuming in the page constuctuor the lawPanel.setOutputMarkupId(true) method was called. public void populateItem(final Item item) { AjaxFallbackLink link = new AjaxFallbackLink("linkViewLaw") { @Override public void onClick(AjaxRequestTarget target) { Law law = (Law) item.getModelObject(); lawPanel.setModelObject (law); if(target != null) { target.addComponent(lawPanel); } } Regards, Mike - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Ajax refresh component
Hi, I would like to do the same page as the Wicket - example source code: - A list of element on the left side - A main page wich displays the details of the selected element My problem is that the element is correctly taken from database but not displayed. Thanks, Here is my code : package com.fred.micro.web; import com.fred.micro.AbstractBasePage; import com.fred.micro.common.TextilMultiLineLabel; import org.apache.wicket.markup.repeater.Item; import com.fred.micro.domain.Law; import com.fred.micro.domain.LawNorm; import com.fred.micro.services.MicrochangesService; import com.fred.micro.web.model.DomainModelIteratorAdaptor; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.wicket.PageParameters; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.navigation.paging.PagingNavigator; import org.apache.wicket.markup.repeater.RefreshingView; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.CompoundPropertyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.spring.injection.annot.SpringBean; /** * Homepage */ public class LawView extends AbstractBasePage { private static final long serialVersionUID = 1L; // TODO Add any page properties or variables here /** * Constructor that is invoked when page is invoked without a session. * * @param parameters *Page parameters */ @SpringBean private MicrochangesService service; public LawView(final PageParameters parameters) { super(); //add(new DataView("laws", new LawProvider()), 1); //List listLaws = service.findAllLaws(); RefreshingView listView = new RefreshingView("laws"){ @Override protected Iterator getItemModels() { return new DomainModelIteratorAdaptor(service .findAllLaws().iterator()) { @Override protected IModel model(Object object) { return new CompoundPropertyModel((Law) object); } }; } public void populateItem(final Item item) { final Law law = (Law) item.getModelObject(); //item.add(new Label("lawUniqueId", String.valueOf(law.getId()) )); AjaxFallbackLink link = new AjaxFallbackLink("linkViewLaw") { @Override public void onClick(AjaxRequestTarget target) { if(target != null) { super.onClick(); Law newLaw = service.getLaw(law.getId()); target.addComponent(new LawPanel("lawPanel", newLaw)); renderComponent(); } } }; link.add(new Label("lawId", law.getLawArticle() + " - " + law.getLawArticleFirstArg() + " - " + law.getLawArticleSecondArg())); item.add(link); } }; add(listView); add(new LawPanel("lawPanel", service.findAllLaws().get(0))); setOutputMarkupId(true); } } MICHAEL
Re: Refresh component from non-wicket js
Mats Norén wrote: Hi, I've been searching the archives on a simple way to repaint a component from a non-wicket javascript, ie the javascript is not attached or associated with a wicket component. The usecase: 1. A user updates data in the browser (non wicket) 2. Presses save (could be a wicket component) 3. An ajax-call is made to update a datasource (non wicket call) 4. Success-handler should repaint a wicket component In 2 I tried with an AjaxButton and requestTarget.prependJavascript("doAjaxSaveInOtherLibrary()").. The problem with that is the timing. The prepended javascript function returns and then the wicket ajaxcall gets executed before the success-handler in the non wicket library... I guess what I'm looking for is a simple way to add a markupcontainer with an AbstractDefaultAjaxBehavior that I can reference from my non wicket javascript. Hi Mats, how about this (pseudo code): componentYouWantToPressOnForSave.add(new AjaxEventBehavior("onclick") { protected CharSequence getCallbackScript(boolean onlyTargetActivePage) { return generateCallbackScript("doAjaxSaveInOtherLibrary('" + getCallbackUrl(onlyTargetActivePage) + "'"); } ); than you can decide if you want to initiate the AjaxCall to the AjaxEventBehavior or not. Just call wicketAjaxGet(callbackUrl) somewhere in your JavaScript on success-handler. mf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Refresh component from non-wicket js
Hi, I've been searching the archives on a simple way to repaint a component from a non-wicket javascript, ie the javascript is not attached or associated with a wicket component. The usecase: 1. A user updates data in the browser (non wicket) 2. Presses save (could be a wicket component) 3. An ajax-call is made to update a datasource (non wicket call) 4. Success-handler should repaint a wicket component In 2 I tried with an AjaxButton and requestTarget.prependJavascript("doAjaxSaveInOtherLibrary()").. The problem with that is the timing. The prepended javascript function returns and then the wicket ajaxcall gets executed before the success-handler in the non wicket library... I guess what I'm looking for is a simple way to add a markupcontainer with an AbstractDefaultAjaxBehavior that I can reference from my non wicket javascript. Any suggestions? /Mats - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
Johan Compagner wrote: > > it should work fine. > I updated from rc1 to rc2 and it works!!! Thanks! Artur -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14399364.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
it should work fine. A self updating timer only works once.. as far as i know then it does the call. And the SelfUpdating add its component back to the ajax request target so that normally the timer is inserted again and started when the ajax request finishes. and the isEnabled() is checked when the component renders its behaviors. johan On Dec 18, 2007 2:15 PM, Matej Knopp <[EMAIL PROTECTED]> wrote: > I'm not entirely sure isEnabled() works properly on timer behaviors. > If it doesn't please add a feature request, the current implementation > is way too simplistic and needs to be enhanced. > > -Matej > > On Dec 18, 2007 12:43 PM, Artur W. <[EMAIL PROTECTED]> wrote: > > > > > > Alex Objelean wrote: > > > > > > AjaxSelfUpdatingTimerBehavior implements IBehavior interface, which > has > > > the following method: > > > boolean isEnabled(Component component); > > > > > > Override it and provide your business logic there. > > > > > > > I must do something wrong becouse it doesn't start refreshing. > > > > My refreshing label: > > > > counterLabel.add(new AjaxSelfUpdatingTimerBehavior( > Duration.seconds(2)) { > > @Override > > protected void > onPostProcessTarget(AjaxRequestTarget target) { > > if (counter == 0 && confirmed) { > > window.close(target); > > } > > } > > @Override > > public boolean isEnabled(Component component) { > > return confirmed; > > } > > }); > > counterLabel.setOutputMarkupId(true); > > add(counterLabel); > > > > My confirm button: > > > > form.add(new IndicatingAjaxButton("confirmButton", form) > { > > @Override > > protected void onSubmit(final AjaxRequestTarget > target, Form form) { > > > > confirmed = true; > > > > > > setEnabled(false); > > setOutputMarkupId(true); > > > > new Thread() { > > > > public void run() { > > //do something here > > counter--; > > } > > > > }.start(); > > target.addComponent(this); > > target.addComponent(counterLabel); > > } > > > > Artur > > > > -- > > View this message in context: > http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14395329.html > > > > Sent from the Wicket - User mailing list archive at > > Nabble.com<http://nabble.com/> > . > > > > > > - > > 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] > >
Re: How to refresh component many times in one ajax request
Nope thats already done: * final* Iterator iter = behaviors.iterator(); *while* (iter.hasNext()) { IBehavior behavior = (IBehavior)iter.next(); *if* (behavior *instanceof* IHeaderContributor && isBehaviorAccepted(behavior)) { ((IHeaderContributor)behavior).renderHead(container.getHeaderResponse()); } } On Dec 18, 2007 2:24 PM, Gerolf Seitz <[EMAIL PROTECTED]> wrote: > On Dec 18, 2007 2:15 PM, Matej Knopp <[EMAIL PROTECTED]> wrote: > > > I'm not entirely sure isEnabled() works properly on timer behaviors. > > If it doesn't please add a feature request, the current implementation > > is way too simplistic and needs to be enhanced. > > > > seems like we need to check for isEnabled(Component) in #renderHead > > Gerolf > > > > > > -Matej > > > > On Dec 18, 2007 12:43 PM, Artur W. <[EMAIL PROTECTED]> wrote: > > > > > > > > > Alex Objelean wrote: > > > > > > > > AjaxSelfUpdatingTimerBehavior implements IBehavior interface, which > > has > > > > the following method: > > > > boolean isEnabled(Component component); > > > > > > > > Override it and provide your business logic there. > > > > > > > > > > I must do something wrong becouse it doesn't start refreshing. > > > > > > My refreshing label: > > > > > > counterLabel.add(new AjaxSelfUpdatingTimerBehavior( > > Duration.seconds(2)) { > > > @Override > > > protected void > > onPostProcessTarget(AjaxRequestTarget target) { > > > if (counter == 0 && confirmed) { > > > window.close(target); > > > } > > > } > > > @Override > > > public boolean isEnabled(Component component) > { > > > return confirmed; > > > } > > > }); > > > counterLabel.setOutputMarkupId(true); > > > add(counterLabel); > > > > > > My confirm button: > > > > > > form.add(new IndicatingAjaxButton("confirmButton", > form) > > { > > > @Override > > > protected void onSubmit(final > AjaxRequestTarget > > target, Form form) { > > > > > > confirmed = true; > > > > > > > > > setEnabled(false); > > > setOutputMarkupId(true); > > > > > > new Thread() { > > > > > > public void run() { > > > //do something here > > > counter--; > > > } > > > > > > }.start(); > > > target.addComponent(this); > > > target.addComponent(counterLabel); > > > } > > > > > > Artur > > > > > > -- > > > View this message in context: > > > http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14395329.html > > > > > > Sent from the Wicket - User mailing list archive at > > > Nabble.com<http://nabble.com/> > . > > > > > > > > > - > > > 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] > > > > >
Re: How to refresh component many times in one ajax request
On Dec 18, 2007 2:15 PM, Matej Knopp <[EMAIL PROTECTED]> wrote: > I'm not entirely sure isEnabled() works properly on timer behaviors. > If it doesn't please add a feature request, the current implementation > is way too simplistic and needs to be enhanced. > seems like we need to check for isEnabled(Component) in #renderHead Gerolf > > -Matej > > On Dec 18, 2007 12:43 PM, Artur W. <[EMAIL PROTECTED]> wrote: > > > > > > Alex Objelean wrote: > > > > > > AjaxSelfUpdatingTimerBehavior implements IBehavior interface, which > has > > > the following method: > > > boolean isEnabled(Component component); > > > > > > Override it and provide your business logic there. > > > > > > > I must do something wrong becouse it doesn't start refreshing. > > > > My refreshing label: > > > > counterLabel.add(new AjaxSelfUpdatingTimerBehavior( > Duration.seconds(2)) { > > @Override > > protected void > onPostProcessTarget(AjaxRequestTarget target) { > > if (counter == 0 && confirmed) { > > window.close(target); > > } > > } > > @Override > > public boolean isEnabled(Component component) { > > return confirmed; > > } > > }); > > counterLabel.setOutputMarkupId(true); > > add(counterLabel); > > > > My confirm button: > > > > form.add(new IndicatingAjaxButton("confirmButton", form) > { > > @Override > > protected void onSubmit(final AjaxRequestTarget > target, Form form) { > > > > confirmed = true; > > > > > > setEnabled(false); > > setOutputMarkupId(true); > > > > new Thread() { > > > > public void run() { > > //do something here > > counter--; > > } > > > > }.start(); > > target.addComponent(this); > > target.addComponent(counterLabel); > > } > > > > Artur > > > > -- > > View this message in context: > http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14395329.html > > > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > > > > - > > 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] > >
Re: How to refresh component many times in one ajax request
I'm not entirely sure isEnabled() works properly on timer behaviors. If it doesn't please add a feature request, the current implementation is way too simplistic and needs to be enhanced. -Matej On Dec 18, 2007 12:43 PM, Artur W. <[EMAIL PROTECTED]> wrote: > > > Alex Objelean wrote: > > > > AjaxSelfUpdatingTimerBehavior implements IBehavior interface, which has > > the following method: > > boolean isEnabled(Component component); > > > > Override it and provide your business logic there. > > > > I must do something wrong becouse it doesn't start refreshing. > > My refreshing label: > > counterLabel.add(new > AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) { > @Override > protected void onPostProcessTarget(AjaxRequestTarget > target) { > if (counter == 0 && confirmed) { > window.close(target); > } > } > @Override > public boolean isEnabled(Component component) { > return confirmed; > } > }); > counterLabel.setOutputMarkupId(true); > add(counterLabel); > > My confirm button: > > form.add(new IndicatingAjaxButton("confirmButton", form) { > @Override > protected void onSubmit(final AjaxRequestTarget > target, Form form) { > > confirmed = true; > > > setEnabled(false); > setOutputMarkupId(true); > > new Thread() { > > public void run() { > //do something here > counter--; > } > > }.start(); > target.addComponent(this); > target.addComponent(counterLabel); > } > > Artur > > -- > View this message in context: > http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14395329.html > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > 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]
Re: How to refresh component many times in one ajax request
Alex Objelean wrote: > > AjaxSelfUpdatingTimerBehavior implements IBehavior interface, which has > the following method: > boolean isEnabled(Component component); > > Override it and provide your business logic there. > I must do something wrong becouse it doesn't start refreshing. My refreshing label: counterLabel.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) { @Override protected void onPostProcessTarget(AjaxRequestTarget target) { if (counter == 0 && confirmed) { window.close(target); } } @Override public boolean isEnabled(Component component) { return confirmed; } }); counterLabel.setOutputMarkupId(true); add(counterLabel); My confirm button: form.add(new IndicatingAjaxButton("confirmButton", form) { @Override protected void onSubmit(final AjaxRequestTarget target, Form form) { confirmed = true; setEnabled(false); setOutputMarkupId(true); new Thread() { public void run() { //do something here counter--; } }.start(); target.addComponent(this); target.addComponent(counterLabel); } Artur -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14395329.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
AjaxSelfUpdatingTimerBehavior implements IBehavior interface, which has the following method: boolean isEnabled(Component component); Override it and provide your business logic there. Alex. Artur W. wrote: > > > Alex Objelean wrote: >> >> I think that the better approach would be to enable/disable the behavior, >> instead of adding it. >> > > Is there a convenience method to do this? > > There is no enable/disable method in the AjaxSelfUpdatingTimerBehavior. > > > Thanks, > Artur > > -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14393058.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
Alex Objelean wrote: > > I think that the better approach would be to enable/disable the behavior, > instead of adding it. > Is there a convenience method to do this? There is no enable/disable method in the AjaxSelfUpdatingTimerBehavior. Thanks, Artur -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14391636.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
I think that the better approach would be to enable/disable the behavior, instead of adding it. Alex. Artur W. wrote: > > Btw, is is possible to add Behavior to the component in the > AjaxRequestTarget? > For exampel I want to add AjaxSelfUpdatingTimerBehavior but when the user > click on the button. > > > Thanks, > Artur > -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14387677.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
Gerolf Seitz wrote: > > On Dec 17, 2007 10:33 PM, Artur W. <[EMAIL PROTECTED]> wrote: > >> >> The component doesn't refresh. Only for the last time. How to make it >> work? >> > > that's because the response is sent *AFTER* loop is over, not when > target.addComponent(..) is called. > what you need is a AjaxSelfUpdatingTimerBehavior, override > onPostProcessTarget and do counter = counter +1; in there. > Thanks for reply Guys! My business case is much more complicated. This was just simple example. I did like you said. It was interested that I had to start new thread to process the loop. Without it the label didn't refresh the counter value. Here is my code, maybe it would be helpful for someone else: this.counter = 100 final Label counterLabel = new Label("counter", new PropertyModel(this, "counter")); counterLabel.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(3)) { @Override protected void onPostProcessTarget(AjaxRequestTarget target) { if (counter == 0) { //close the window after countdown :) window.close(target); } } }); counterLabel.setOutputMarkupId(true); add(counterLabel); Form form = new Form("form"); add(form); form.add(new IndicatingAjaxButton("confirmButton", form) { @Override protected void onSubmit(final AjaxRequestTarget target, Form form) { setEnabled(false); setOutputMarkupId(true); target.addComponent(this); new Thread() { public void run() { for (int i = 0; i < 100; i++ ) { synchronized (this) { //do business here ;) try { wait(300); } catch (InterruptedException e) { e.printStackTrace(); } counter--; } } } }.start(); } }); Btw, is is possible to add Behavior to the component in the AjaxRequestTarget? For exampel I want to add AjaxSelfUpdatingTimerBehavior but when the user click on the button. Thanks, Artur -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14387672.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
What you're doing right now is to send a request to the server, iterate a hundred times, replace a component a hundred times, even before the response from the server reaches the client again. That what you want to achieve would involve 100 ajax requests and responses, it IS feasable, but better try a javascript-solution, because 100 roundtrips is just too much if it's just for changing the label to a fixed value. But if it's more than that, AjaxSelfUpdatingBehavior might be your friend Artur W. wrote: > > Hi! > > I try to do something like this > > final Label counterLabel = new Label("counter", new > PropertyModel(this, > "counter")); > counterLabel.setOutputMarkupId(true); > add(counterLabel); > > Form form = new Form("form"); > add(form); > > form.add(new AjaxButton("confirmButton") { > @Override > protected void onSubmit(AjaxRequestTarget target, Form > form) { > for (int i=0; i <100; i++ ) { > synchronized (this) { > try { > wait(1000); > } catch (InterruptedException > e) { > e.printStackTrace(); > } > counter += i; > > target.addComponent(counterLabel); > } > } > } > }); > > > The component doesn't refresh. Only for the last time. How to make it > work? > > > Thanks, > Artur > > - Michael Sparer http://talk-on-tech.blogspot.com -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14384523.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to refresh component many times in one ajax request
On Dec 17, 2007 10:33 PM, Artur W. <[EMAIL PROTECTED]> wrote: > > The component doesn't refresh. Only for the last time. How to make it > work? > that's because the response is sent *AFTER* loop is over, not when target.addComponent(..) is called. what you need is a AjaxSelfUpdatingTimerBehavior, override onPostProcessTarget and do counter = counter +1; in there. hth, Gerolf > > > Thanks, > Artur > > -- > View this message in context: > http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14374053.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
How to refresh component many times in one ajax request
Hi! I try to do something like this final Label counterLabel = new Label("counter", new PropertyModel(this, "counter")); counterLabel.setOutputMarkupId(true); add(counterLabel); Form form = new Form("form"); add(form); form.add(new AjaxButton("confirmButton") { @Override protected void onSubmit(AjaxRequestTarget target, Form form) { for (int i=0; i <100; i++ ) { synchronized (this) { try { wait(1000); } catch (InterruptedException e) { e.printStackTrace(); } counter += i; target.addComponent(counterLabel); } } } }); The component doesn't refresh. Only for the last time. How to make it work? Thanks, Artur -- View this message in context: http://www.nabble.com/How-to-refresh-component-many-times-in-one-ajax-request-tp14374053p14374053.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]