Feedback messages not showing on first request

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Feedback messages not showing on first request

Entropy
We have a page where we are being required to have multiple feedback panels,
and to show messages in various ones depending on the error.  Our solution
was to use message filters and to put the messages against certain
containers to say 'any message in container X goes to feedback panel X'.  

You can see the code below for example.  The request thing is just to set
the class of the feedbackpanel to a different value.  But we also control
the visibility of the panel by checking 'anyMessage()'.  So if there's no
errors, no feedback shows.  

This all works...except on the first request.  For some reason when I click
the button, I can see the error (it's added during the onSubmit(), not
during the normal validation step if that makes a difference) added to the
assetLookupOptionsWMC, but then when anyMessage() runs, it doesn't find the
error.  Click the button a second time, and it works perfectly.

Any idea why?

                assetLookupOptionsFP.setFilter(new IFeedbackMessageFilter(){
                        private static final long serialVersionUID = 1L;

                        @Override
                        public boolean accept(FeedbackMessage msg) {
                                Component reporter = msg.getReporter();
                                HttpServletRequest request = ((HttpServletRequest)
getRequest().getContainerRequest());
                               
                                if (reporter.getId().equals("assetLookupOptionsWMC")){
                                        if(msg.isError())
                                                request.setAttribute("assetLookupOptionsFeedbackPanelHasError",
"TRUE");
                                        return true;
                                } else if
(reporter.getParent().getId().equals("assetLookupOptionsWMC")){
                                        if(msg.isError())
                                                request.setAttribute("assetLookupOptionsFeedbackPanelHasError",
"TRUE");
                                        return true;
                                } else {
                                        return false;
                                }
                        }
                       
                });

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Feedback messages not showing on first request

Sven Meier
Hi,

hard to tell from your code snippet.

Could you remove the irrelevant part (the request attribute) and show us
the visibility control instead?

A quickstart would help too.

Have fun
Sven


On 26.11.19 16:53, Entropy wrote:

> We have a page where we are being required to have multiple feedback panels,
> and to show messages in various ones depending on the error.  Our solution
> was to use message filters and to put the messages against certain
> containers to say 'any message in container X goes to feedback panel X'.
>
> You can see the code below for example.  The request thing is just to set
> the class of the feedbackpanel to a different value.  But we also control
> the visibility of the panel by checking 'anyMessage()'.  So if there's no
> errors, no feedback shows.
>
> This all works...except on the first request.  For some reason when I click
> the button, I can see the error (it's added during the onSubmit(), not
> during the normal validation step if that makes a difference) added to the
> assetLookupOptionsWMC, but then when anyMessage() runs, it doesn't find the
> error.  Click the button a second time, and it works perfectly.
>
> Any idea why?
>
> assetLookupOptionsFP.setFilter(new IFeedbackMessageFilter(){
> private static final long serialVersionUID = 1L;
>
> @Override
> public boolean accept(FeedbackMessage msg) {
> Component reporter = msg.getReporter();
> HttpServletRequest request = ((HttpServletRequest)
> getRequest().getContainerRequest());
>
> if (reporter.getId().equals("assetLookupOptionsWMC")){
> if(msg.isError())
> request.setAttribute("assetLookupOptionsFeedbackPanelHasError",
> "TRUE");
> return true;
> } else if
> (reporter.getParent().getId().equals("assetLookupOptionsWMC")){
> if(msg.isError())
> request.setAttribute("assetLookupOptionsFeedbackPanelHasError",
> "TRUE");
> return true;
> } else {
> return false;
> }
> }
>
> });
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Feedback messages not showing on first request

Entropy
The isVisible():

                assetLookupOptionsFP = new FeedbackPanel("assetLookupOptionsFP"){
                        private static final long serialVersionUID = 1L;
                       
                        @Override
                        public boolean isVisible() {
                                if (anyMessage()){
                                        return true;
                                } else {
                                        return false;
                                }
                        }
                };

--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Feedback messages not showing on first request

Sven Meier
Hi,

your isVisible() might be called to often or early.

FeedbackMessagesModel caches the messages during request, so the call to
#anyMessage() might result in a premature collection of messages.

Try override #onConfigure() instead, this is preferred over overriding
#isVisible():

             @Override
             protected void onConfigure()
             {
                 super.onConfigure();
                 setVisible(anyMessage());
             }

Have fun
Sven


On 02.12.19 14:32, Entropy wrote:

> The isVisible():
>
> assetLookupOptionsFP = new FeedbackPanel("assetLookupOptionsFP"){
> private static final long serialVersionUID = 1L;
>
> @Override
> public boolean isVisible() {
> if (anyMessage()){
> return true;
> } else {
> return false;
> }
> }
> };
>
> --
> Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]