You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by an...@apache.org on 2007/04/23 03:15:34 UTC

svn commit: r531308 - /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java

Author: andyhot
Date: Sun Apr 22 18:15:33 2007
New Revision: 531308

URL: http://svn.apache.org/viewvc?view=rev&rev=531308
Log:
Support adding status messages to an XHR response. No changes yet to the ResponseBuilder interface, you'll have to cast to DojoAjaxResponseBuilder to use this for now

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java?view=diff&rev=531308&r1=531307&r2=531308
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java Sun Apr 22 18:15:33 2007
@@ -69,6 +69,8 @@
     private List _parts = new ArrayList();
     // Map of specialized writers, like scripts
     private Map _writers = new HashMap();
+    // List of status messages.
+    private List _statusMessages;
     
     private IRequestCycle _cycle;
     
@@ -492,6 +494,30 @@
         
         writer.end();
     }
+        
+    public void addStatus(IMarkupWriter normalWriter, String text)
+    {
+        addStatus(normalWriter, text, "info");
+    }  
+    
+    public void addStatus(IMarkupWriter normalWriter, String text, String category)
+    {
+        if (_statusMessages==null)
+        {
+            _statusMessages = new ArrayList();
+        }
+        _statusMessages.add(category);
+        _statusMessages.add(text);        
+    }
+    
+    void writeStatusMessages() {
+        for (int i=0; i<_statusMessages.size(); i+=2)
+        {
+            IMarkupWriter writer = getWriter((String) _statusMessages.get(i), "status");
+            writer.printRaw((String) _statusMessages.get(i+1));                
+        }
+        _statusMessages = null;            
+    }
     
     /** 
      * {@inheritDoc}
@@ -632,6 +658,8 @@
     void endResponse()
     {
         // write out captured content
+        if (_statusMessages != null)        
+            writeStatusMessages();
         
         Iterator keys = _writers.keySet().iterator();
         String buffer = null;



Re: svn commit: r531308 - /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java

Posted by Andreas Andreou <an...@di.uoa.gr>.
Of course, you wont have to cast in order to use this...

I did it this way in order to (perhaps) get some comments on the methods'
signature before also changing the interface - that's what i was trying to
describe
in the commit message!


On 4/23/07, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> I like the addition of course, but have to ask - is there really a plan
> for
> adding an impl for this for the other response builders?  I only ask
> because
> it looks like one of those things that might not ever get implemented in
> the
> others - and I don't like the idea of telling people to cast.
>
> If you do have plans please ignore - if not - I would add a no-op for this
> in the builders so no casting is required.
>
> On 4/22/07, andyhot@apache.org <an...@apache.org> wrote:
> >
> > Author: andyhot
> > Date: Sun Apr 22 18:15:33 2007
> > New Revision: 531308
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=531308
> > Log:
> > Support adding status messages to an XHR response. No changes yet to the
> > ResponseBuilder interface, you'll have to cast to
> DojoAjaxResponseBuilder to
> > use this for now
> >
> > Modified:
> >
> >
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> >
> > Modified:
> >
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> > URL:
> >
> http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java?view=diff&rev=531308&r1=531307&r2=531308
> >
> >
> ==============================================================================
> > ---
> >
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> > (original)
> > +++
> >
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> > Sun Apr 22 18:15:33 2007
> > @@ -69,6 +69,8 @@
> >      private List _parts = new ArrayList();
> >      // Map of specialized writers, like scripts
> >      private Map _writers = new HashMap();
> > +    // List of status messages.
> > +    private List _statusMessages;
> >
> >      private IRequestCycle _cycle;
> >
> > @@ -492,6 +494,30 @@
> >
> >          writer.end();
> >      }
> > +
> > +    public void addStatus(IMarkupWriter normalWriter, String text)
> > +    {
> > +        addStatus(normalWriter, text, "info");
> > +    }
> > +
> > +    public void addStatus(IMarkupWriter normalWriter, String text,
> String
> > category)
> > +    {
> > +        if (_statusMessages==null)
> > +        {
> > +            _statusMessages = new ArrayList();
> > +        }
> > +        _statusMessages.add(category);
> > +        _statusMessages.add(text);
> > +    }
> > +
> > +    void writeStatusMessages() {
> > +        for (int i=0; i<_statusMessages.size(); i+=2)
> > +        {
> > +            IMarkupWriter writer = getWriter((String)
> > _statusMessages.get(i), "status");
> > +            writer.printRaw((String) _statusMessages.get(i+1));
> > +        }
> > +        _statusMessages = null;
> > +    }
> >
> >      /**
> >       * {@inheritDoc}
> > @@ -632,6 +658,8 @@
> >      void endResponse()
> >      {
> >          // write out captured content
> > +        if (_statusMessages != null)
> > +            writeStatusMessages();
> >
> >          Iterator keys = _writers.keySet().iterator();
> >          String buffer = null;
> >
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>



-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

Re: svn commit: r531308 - /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java

Posted by Jesse Kuhnert <jk...@gmail.com>.
I like the addition of course, but have to ask - is there really a plan for
adding an impl for this for the other response builders?  I only ask because
it looks like one of those things that might not ever get implemented in the
others - and I don't like the idea of telling people to cast.

If you do have plans please ignore - if not - I would add a no-op for this
in the builders so no casting is required.

On 4/22/07, andyhot@apache.org <an...@apache.org> wrote:
>
> Author: andyhot
> Date: Sun Apr 22 18:15:33 2007
> New Revision: 531308
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=531308
> Log:
> Support adding status messages to an XHR response. No changes yet to the
> ResponseBuilder interface, you'll have to cast to DojoAjaxResponseBuilder to
> use this for now
>
> Modified:
>
>     tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
>
> Modified:
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> URL:
> http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java?view=diff&rev=531308&r1=531307&r2=531308
>
> ==============================================================================
> ---
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> (original)
> +++
> tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/DojoAjaxResponseBuilder.java
> Sun Apr 22 18:15:33 2007
> @@ -69,6 +69,8 @@
>      private List _parts = new ArrayList();
>      // Map of specialized writers, like scripts
>      private Map _writers = new HashMap();
> +    // List of status messages.
> +    private List _statusMessages;
>
>      private IRequestCycle _cycle;
>
> @@ -492,6 +494,30 @@
>
>          writer.end();
>      }
> +
> +    public void addStatus(IMarkupWriter normalWriter, String text)
> +    {
> +        addStatus(normalWriter, text, "info");
> +    }
> +
> +    public void addStatus(IMarkupWriter normalWriter, String text, String
> category)
> +    {
> +        if (_statusMessages==null)
> +        {
> +            _statusMessages = new ArrayList();
> +        }
> +        _statusMessages.add(category);
> +        _statusMessages.add(text);
> +    }
> +
> +    void writeStatusMessages() {
> +        for (int i=0; i<_statusMessages.size(); i+=2)
> +        {
> +            IMarkupWriter writer = getWriter((String)
> _statusMessages.get(i), "status");
> +            writer.printRaw((String) _statusMessages.get(i+1));
> +        }
> +        _statusMessages = null;
> +    }
>
>      /**
>       * {@inheritDoc}
> @@ -632,6 +658,8 @@
>      void endResponse()
>      {
>          // write out captured content
> +        if (_statusMessages != null)
> +            writeStatusMessages();
>
>          Iterator keys = _writers.keySet().iterator();
>          String buffer = null;
>
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com