You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Woodchuck <wo...@yahoo.com> on 2005/05/02 23:09:45 UTC

[OT] Re: ajax proj

JSTL is da bomb!  :)

--- Rick Reumann <st...@reumann.net> wrote:
> Dakota Jack wrote the following on 5/2/2005 4:01 PM:
> > 
> > The other aspect that is not discussed above is the removal of the
> > complexity from the "page".  This is where JSP, Taglibs, etc., come
> > into the picture.  And, I suspect, you two are talking about a
> > combination of this problem (keeping the page simple) and the
> previous
> > problem (using a reasonable architecture).
> 
> yes. For example, take a table sort example. I like being able to use
> 
> JSTL (or even a display tag if that suits you) to display the
> collection 
> info into the display of the table.
> 
> Doing something like this within a servlet (Action) wouldn't really
> be 
> wrong, but just more difficult to maintain and more of pain to code 
> (using StringBuffer and append bla bla).
> 
> -- 
> Rick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: ajax proj

Posted by Craig McClanahan <cr...@gmail.com>.
On 5/2/05, Jason Lea <ja...@kumachan.net.nz> wrote:
> Just a quick note/question about Craig's code below:
> 
> This line
> 
>     <label>${category.label}</label>
> 
>  will output the value with not xml filtering, so some values will cause
> incorrect xml to be generated.
> 
> You should use <c:out> tag to filter the <,>,',", and & characters to
> output &lt;, &gt;, &apos;, &quot;, and &amp;
> 
>     <label><c:out value="${category.label}"/></label>
> 
> and the same for the <value> element
> 

Yep ... +1 on that suggestion.

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: ajax proj

Posted by Jason Lea <ja...@kumachan.net.nz>.
Just a quick note/question about Craig's code below:

This line

    <label>${category.label}</label>

 will output the value with not xml filtering, so some values will cause 
incorrect xml to be generated.

You should use <c:out> tag to filter the <,>,',", and & characters to 
output &lt;, &gt;, &apos;, &quot;, and &amp;

    <label><c:out value="${category.label}"/></label>

and the same for the <value> element

Craig McClanahan wrote:

>On 5/2/05, Woodchuck <wo...@yahoo.com> wrote:
>
>  
>
>>JSTL is da bomb!  :)
>>    
>>
>
>Indeed it is.  If you actually need to create XML in a response to an
>XmlHttpRequest call from an Ajax client side gadget :-), here's an
>approach using a JSP 2.0 page (in xml syntax) that uses JSTL to
>iterate over a result set, and JSP expressions to pull out the data
>(copied from the Shale Use Cases example app):
>
>--------------------
><jsp:root             version="2.0"
>                      xmlns:c="http://java.sun.com/jsp/jstl/core"
>                    xmlns:jsp="http://java.sun.com/JSP/Page">
>
>  <jsp:directive.page
>                  contentType="text/xml;charset=UTF-8"/>
>
>  <categories>
>    <c:forEach            var="category"
>                        items="${lookup$listCategories.supportedCategories}">
>      <category>
>        <label>${category.label}</label>
>        <value>${category.value}</value>
>      </category>
>    </c:forEach>
>  </categories>
>
></jsp:root>
>
>--------------------
>
>The business logic that looks up the label/value pairs for the
>response doesn't have a clue how it will actually be rendered, and
>setting up a JSP page is much easier to author than building an XML
>DOM in Java code.
>
>Craig
>
>
>  
>
>>--- Rick Reumann <st...@reumann.net> wrote:
>>    
>>
>>>Dakota Jack wrote the following on 5/2/2005 4:01 PM:
>>>      
>>>
>>>>The other aspect that is not discussed above is the removal of the
>>>>complexity from the "page".  This is where JSP, Taglibs, etc., come
>>>>into the picture.  And, I suspect, you two are talking about a
>>>>combination of this problem (keeping the page simple) and the
>>>>        
>>>>
>>>previous
>>>      
>>>
>>>>problem (using a reasonable architecture).
>>>>        
>>>>
>>>yes. For example, take a table sort example. I like being able to use
>>>
>>>JSTL (or even a display tag if that suits you) to display the
>>>collection
>>>info into the display of the table.
>>>
>>>Doing something like this within a servlet (Action) wouldn't really
>>>be
>>>wrong, but just more difficult to maintain and more of pain to code
>>>(using StringBuffer and append bla bla).
>>>
>>>--
>>>Rick
>>>
>>>      
>>>

-- 
Jason Lea



Re: [OT] Re: ajax proj

Posted by Craig McClanahan <cr...@gmail.com>.
On 5/2/05, Woodchuck <wo...@yahoo.com> wrote:

> JSTL is da bomb!  :)

Indeed it is.  If you actually need to create XML in a response to an
XmlHttpRequest call from an Ajax client side gadget :-), here's an
approach using a JSP 2.0 page (in xml syntax) that uses JSTL to
iterate over a result set, and JSP expressions to pull out the data
(copied from the Shale Use Cases example app):

--------------------
<jsp:root             version="2.0"
                      xmlns:c="http://java.sun.com/jsp/jstl/core"
                    xmlns:jsp="http://java.sun.com/JSP/Page">

  <jsp:directive.page
                  contentType="text/xml;charset=UTF-8"/>

  <categories>
    <c:forEach            var="category"
                        items="${lookup$listCategories.supportedCategories}">
      <category>
        <label>${category.label}</label>
        <value>${category.value}</value>
      </category>
    </c:forEach>
  </categories>

</jsp:root>

--------------------

The business logic that looks up the label/value pairs for the
response doesn't have a clue how it will actually be rendered, and
setting up a JSP page is much easier to author than building an XML
DOM in Java code.

Craig


> 
> --- Rick Reumann <st...@reumann.net> wrote:
> > Dakota Jack wrote the following on 5/2/2005 4:01 PM:
> > >
> > > The other aspect that is not discussed above is the removal of the
> > > complexity from the "page".  This is where JSP, Taglibs, etc., come
> > > into the picture.  And, I suspect, you two are talking about a
> > > combination of this problem (keeping the page simple) and the
> > previous
> > > problem (using a reasonable architecture).
> >
> > yes. For example, take a table sort example. I like being able to use
> >
> > JSTL (or even a display tag if that suits you) to display the
> > collection
> > info into the display of the table.
> >
> > Doing something like this within a servlet (Action) wouldn't really
> > be
> > wrong, but just more difficult to maintain and more of pain to code
> > (using StringBuffer and append bla bla).
> >
> > --
> > Rick
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] Re: ajax proj

Posted by Dave Newton <ne...@pingsite.com>.
Woodchuck wrote:

>JSTL is da bomb!  :)
>  
>
Does this mean... we can drop it?

Eh, it's Friday, whaddya want.

Seriously, I hate all that typing-JSP 2.0 may save my wrists.

Dave "What do you mean, Monday?" Newton



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org