You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Piller Sébastien <pi...@hmcrecord.ch> on 2009/02/09 14:27:23 UTC

[WicketStuff] Progress bar, tasks and feedback messages

Hello,

I'm using wicketstuff-progressbar and it works very well (great job 
Christopher!). I was wondering how I can add feedbacks messages to the 
process (I need to display some warning informations when some work has 
been done but not completely).

I tried both /Task#warn/ and /Session#warn/. /Task#warn/ doesn't work 
(my feedback panel stays empty, even when I try to refresh it with 
/AjaxRequestTarget#addComponent/), and Session#warn throw an exception 
(/IllegalStateException, you can only locate or create sessions in the 
context of a request cycle/)

I've searched the doc and the example, but couldn't find any example of 
this feature.

Any clue?

Thank you ;)

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


Re: [WicketStuff] Progress bar, tasks and feedback messages

Posted by Piller Sébastien <pi...@hmcrecord.ch>.
I found a way, if anybody needs it:

...
final ProgressBar bar = new ProgressBar("progress2", progressionModel) {
            @Override
            protected void onFinished(AjaxRequestTarget target) {
                ITaskService taskService = getTaskService();
                Long taskId = progressionModel.getTaskId();

                int errors = 0;
                int warns = 0;

                for (Message m : taskService.getMessages(taskId)) {
                    switch (m.severity) {
                    case INFO:
                        getSession().info(m.messageKey);
                        break;
                    case WARN:
                        warns++;
                        getSession().warn(m.messageKey);
                        break;
                    case ERROR:
                        errors++;
                        getSession().error(m.messageKey);
                        break;
                    }
                }

                if (target != null) {
                    if (errors == 0) {
                        if (warns == 0) {
                            target.appendJavascript("alert('Task 
done!\\nTâche terminée!\\nArbeit fertig!')");
                        } else {
                            target.appendJavascript("alert('Task done, 
with " + warns + " warnings!\\nTâche terminée, avec " + warns
                                    + " warnings!\\nArbeit fertig, mit " 
+ warns + " warnings!')");
                        }
                    } else {
                        target.appendJavascript("alert('Warning! There 
was " + errors + " error(s)!\\nAttention! Il y a eu " + errors
                                + " erreur(s)!\\nAchtung! Es ist " + 
errors + " Fehler(n)!')");
                    }
                }
                taskService.finish(taskId);
                setVisible(false);
            }
...


Works well ;)


Piller Sébastien a écrit :
> Hello,
>
> I'm using wicketstuff-progressbar and it works very well (great job 
> Christopher!). I was wondering how I can add feedbacks messages to the 
> process (I need to display some warning informations when some work 
> has been done but not completely).
>
> I tried both /Task#warn/ and /Session#warn/. /Task#warn/ doesn't work 
> (my feedback panel stays empty, even when I try to refresh it with 
> /AjaxRequestTarget#addComponent/), and Session#warn throw an exception 
> (/IllegalStateException, you can only locate or create sessions in the 
> context of a request cycle/)
>
> I've searched the doc and the example, but couldn't find any example 
> of this feature.
>
> Any clue?
>
> Thank you ;)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


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