Hi Deniel,

Thank you for your help!
It works after I correct my request tool by making it implement
Recyclable and make the dispose() calls refresh().

A summary of how I set confirm/alert/error message using turbine-2.3
-------------------------------------------------------
-) in layout/default.vm, add an macro call: #actionMessage()
                        <td align="left" valign="top">
                          #actionMessage()
                          $screen_placeholder
                        </td>

  This checks/display confirm/alert/error messages, if there is one,
display it.

-) the macro actionMessage() is like:
#macro (actionMessage)
#if($affR.ConfirmMessage)
   <p class="confirmmsg">$affR.ConfirmMessage</p>
#end
#if($affR.InfoMessage)
  <p class="infomsg">$affR.InfoMessage</p> 
#end
#if($affR.AlertMessage)
  <p class="alertmsg">$affR.AlertMessage</p>  
#end
#end

where #affR is my Request pull tool

-) in request pull tool,
public class MyRequestTool implements ApplicationTool, Recyclable 
{
        confirmMessage = null;
        infoMessage = null;
        alertMessage = null;
        errorMessage = null;

        public void refresh() 
        {
                confirmMessage = null;
                infoMessage = null;
                alertMessage = null;
                errorMessage = null;
        }

        public Object getInfoMessage() 
        {
                return infoMessage;
        }

        public void setInfoMessage(Object v) 
        {
                this.infoMessage = v;
        }
        
        ...

        public void dispose() 
        { 
                refresh();
        }


-) simply use req tool to setConfirmMessage() etc in your action


Richard


On Tue, 2004-05-25 at 10:38, Daniel wrote:
> Hi Richard,
> 
> Actually, the refresh() method of the ApplicationTool interface is never
> called (only the init() method is called for each new request), so that
> would explain why your messages aren't being cleared.  I think the
> intention of the refesh() method is so that your code can manually call it
> to do the appropriate thing when you need to but it's not called
> automatically.  You can verify this by adding log statements.
> 
> I think to solve your problem you'd want to also implement the Recyclable
> interface.  You can take a look at how it's done with the IntakeTool
> (which is also a request pull tool).
> 
> Regards,
> Daniel
> 
> On Fri, 21 May 2004, Richard Han wrote:
> 
> > You store the confirm/alert/error msg in user's session, but I store
> > them in my request tool, (see the following snippet), what I don't
> > understand is why the message not reset for a request tool (for reqest
> > tool, they should be refreshed upon each request, am I correct?)
> >
> > In my request pull tool class, I have:
> > <snippet>
> >     private Object confirmMessage;
> >     private Object infoMessage;
> >     private Object alertMessage;
> >
> >     public void refresh() {
> >             confirmMessage = null;
> >             infoMessage = null;
> >             alertMessage = null;
> >     }
> >
> >     public Object getConfirmMessage() {
> >             return confirmMessage;
> >     }
> >
> >     public void setConfirmMessage(Object v) {
> >             this.confirmMessage = v;
> >     }
> >     ...
> > </snippet>
> >
> > Thanks!
> >
> > richard
> >
> >
> > On Fri, 2004-05-21 at 16:17, Louis Moore wrote:
> > > I can't tell from your snippet where the message is
> > > actually being stored but if it's in the temp session
> > > data then you have to reset it to empty after showing
> > > the message. Here's a snippet from my Message.vm
> > > template:
> > >
> > > #if(!$data.User.getTemp($nocwebG.Constant.ERROR_MESSAGE,"").equals(""))
> > >  <div
> > > class="errormessage"><p>$nocwebR.addBreaks($!data.User.getTemp($nocwebG.Constant.ERROR_MESSAGE))</div>
> > >
> > > $data.User.setTemp($nocwebG.Constant.ERROR_MESSAGE,"")
> > > #end
> > >
> > > hope it helps,
> > > Lou
> > >
> > > --- Richard Han <[EMAIL PROTECTED]> wrote:
> > > > I tried another way to set confirm/alert/error
> > > > messages
> > > >         - in my layout/default.vm, I have a macro
> > > > #actionMessage()
> > > >                 <td align="left" valign="top">
> > > >                 #actionMessage()
> > > >                 $screen_placeholder
> > > >                 </td>
> > > >         - The macro #actionMessage() uses a request pull
> > > > tool to check
> > > > confirm/alert/error message set within action
> > > > #macro (actionMessage)
> > > >         #if($myReqTool.ConfirmMessage)
> > > >                 <p
> > > >
> > > class="confirmmsg"><strong>$myReqTool.ConfirmMessage</strong></p>
> > > >
> > > >         #end
> > > >
> > > >         #if($myReqTool.AlertMessage)
> > > >                  <p
> > > > class="alertmsg"><strong>$myReqTool</strong></p>
> > > >         #end
> > > > #end
> > > >
> > > > This is basically the way how turbine-3/scarab deals
> > > > with
> > > > confirm/alert/error messasges (if I am correct),
> > > >
> > > > But for reasons I don't know, the confirm/alert
> > > > message is persistent to
> > > > different pages and won't go away.
> > > > Can somebody points out what I am missing? or share
> > > > your way?
> > > >
> > > > Thanks
> > > >
> > > > richard
> > > >
> > > >
> > > >
> > > > On Fri, 2004-05-21 at 11:58, Louis Moore wrote:
> > > > > There's probably a ton of different ways to do
> > > > this,
> > > > > but I've been setting session parameters in my
> > > > java
> > > > > classes, something like:
> > > > >
> > > > > if (!inputOK)
> > > > > {
> > > > >  // alert
> > > > >  data.getUser().setTemp("warningmsg","Bad
> > > > input!");
> > > > >  return;
> > > > > }
> > > > >
> > > > > try
> > > > > {
> > > > >  // success
> > > > >
> > > > data.getUser().setTemp("successmsg","Successful");
> > > > > }
> > > > > catch
> > > > > {
> > > > >  // failure
> > > > >  data.getUser().setTemp("errormsg","Failed");
> > > > > }
> > > > >
> > > > > Then I have a template Message.vm which checks for
> > > > > those parameters and prints the messages if they
> > > > are
> > > > > there, then removes the parameters. This template
> > > > is
> > > > > parsed inside my Default.vm layout so it's on
> > > > every
> > > > > page. I'd also be interested in hearing how other
> > > > > people are doing this.
> > > > >
> > > > > -Lou
> > > > >
> > > > >
> > > > > --- Pradeep Kumar <[EMAIL PROTECTED]> wrote:
> > > > > > Hi Richard,
> > > > > >
> > > > > > You can use javascript for this. On vm page for
> > > > the
> > > > > > click of any button
> > > > > > you can write a java script function which can
> > > > be
> > > > > > used to set
> > > > > > comfirm/alert/error message .
> > > > > > If you have tried some otherway let us know.
> > > > > > Thanks,
> > > > > > Pradeep
> > > > > >
> > > > > > >>> [EMAIL PROTECTED] 5/21/2004 8:44:44 AM >>>
> > > > > > Hi everyone,
> > > > > >
> > > > > > In turbine-2.3, how do you set
> > > > comfirm/alert/error
> > > > > > message ?
> > > > > >
> > > > > > Thank you in advance!
> > > > > >
> > > > > > richard
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > > > 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]
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > __________________________________
> > > > > Do you Yahoo!?
> > > > > Yahoo! Domains  Claim yours for only $14.70/year
> > > > > http://smallbusiness.promotions.yahoo.com/offer
> > > > >
> > > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > > 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]
> > > >
> > >
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Domains  Claim yours for only $14.70/year
> > > http://smallbusiness.promotions.yahoo.com/offer
> > >
> > > ---------------------------------------------------------------------
> > > 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]
> >
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to