You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Edgar Merino <do...@gmail.com> on 2008/10/05 04:44:59 UTC

Wrapped FeedbackPanel and AjaxRequestTarget

Hello once again,

    I've been coding some Panels that might (or might not) use a 
FeedbackPanel to inform about their states, these panels are Ajax 
enabled. Since the feedbackPanel does not reside on the panel itself (it 
is added to the panels parent component), I've decided to come out with 
a wrapper panel that should support this out of the box (shown below), 
the problem is that after calling "infoFeedback("some msg", target)" I 
don't see the message displayed in the Parent component (a WebPage). I 
thought calling FeedbackPanel#getParent()#info(String msg) will do the 
trick, but I guess I was wrong. I would really appreciate any help.

public abstract class FeedbackHolderPanel extends Panel {
    private FeedbackPanel feedbackPanel;
   
    public FeedbackHolderPanel(String id) {
        super(id);
    }
   
    public Panel addFeedbackPanel(FeedbackPanel feedbackPanel) {       
        this.feedbackPanel = feedbackPanel;
        feedbackPanel.setOutputMarkupId(true);
       
        return this;
    }
   
    protected void infoFeedback(String msg, AjaxRequestTarget target) {
        if (feedbackPanel != null) {
            feedbackPanel.getParent().info(msg);
            addToTarget(target);           
        }
    }
   
    .. {same goes for warn and error} ...
   
    protected FeedbackPanel getFeedbackPanel() {
        return feedbackPanel;
    }
   
    private void addToTarget(AjaxRequestTarget target) {
        if (target != null) {
            target.addComponent(feedbackPanel);
        }
    }
}

Thanks in advance
Edgar Merino

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wrapped FeedbackPanel and AjaxRequestTarget

Posted by Edgar Merino <do...@gmail.com>.
Never mind, I guess this can be solved by calling the actual Parent that 
holds the FeedbackPanel:

Component parent = null;
do {
    parent = feedbackPanel.getParent();
} while(parent.getParent() != null);

Regards,
Edgar Merino


Edgar Merino escribió:
> Hello once again,
>
>    I've been coding some Panels that might (or might not) use a 
> FeedbackPanel to inform about their states, these panels are Ajax 
> enabled. Since the feedbackPanel does not reside on the panel itself 
> (it is added to the panels parent component), I've decided to come out 
> with a wrapper panel that should support this out of the box (shown 
> below), the problem is that after calling "infoFeedback("some msg", 
> target)" I don't see the message displayed in the Parent component (a 
> WebPage). I thought calling FeedbackPanel#getParent()#info(String msg) 
> will do the trick, but I guess I was wrong. I would really appreciate 
> any help.
>
> public abstract class FeedbackHolderPanel extends Panel {
>    private FeedbackPanel feedbackPanel;
>      public FeedbackHolderPanel(String id) {
>        super(id);
>    }
>      public Panel addFeedbackPanel(FeedbackPanel feedbackPanel) 
> {              this.feedbackPanel = feedbackPanel;
>        feedbackPanel.setOutputMarkupId(true);
>              return this;
>    }
>      protected void infoFeedback(String msg, AjaxRequestTarget target) {
>        if (feedbackPanel != null) {
>            feedbackPanel.getParent().info(msg);
>            addToTarget(target);                  }
>    }
>      .. {same goes for warn and error} ...
>      protected FeedbackPanel getFeedbackPanel() {
>        return feedbackPanel;
>    }
>      private void addToTarget(AjaxRequestTarget target) {
>        if (target != null) {
>            target.addComponent(feedbackPanel);
>        }
>    }
> }
>
> Thanks in advance
> Edgar Merino
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org