tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Re: Tag List
Date Mon, 17 Feb 2003 16:18:33 GMT
No, I just wrote this as a breif example into the email, Some sections 
were not "finished" (ie have ...) I was primarily trying to show a rough 
layout of a jsp that could handle the different conditions that might 
occur in your case example. You'd have to flesh out the sql queries and 
updates.

Therer are some sql:update tags that are left open in the choose block, 
those are probibly causing the nesting error.

Cheers,
Mark


Scott Taylor wrote:
> Mark
> 
> Am I able to simply overwrite my existing JSP with what you have below?
> Because I tried to compile it in Netbeans and got:
> 
> ProductList.jsp [-1:-1] End of content reached while more parsing required:
> tag nesting error?
> Errors compiling ProductList.
> 
> Scott
> 
> ----- Original Message -----
> From: "Mark R. Diggory" <mdiggory@latte.harvard.edu>
> To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
> Sent: Sunday, February 16, 2003 9:34 PM
> Subject: Re: Tag List
> 
> 
> 
>>Scott,
>>
>>Is this kinda what you mean? Are you trying to add the
>>search/edit/remove/add functionality to the jsp page? This could easily
>>be captured with forms which submit back to the jsp plus a choose block
>>to designate which operation is being performed. I bet this'll really
>>irk those Struts/Maveric MVC folks out there with its use of the JSP
>>page as both the Controller and View. But it is relatively easy to
>>accomplish using JSTL without such "heavy" MVC frameworks.
>>
>>Here is the example:
>>
>><%@page contentType="text/html"%>
>>
>><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
>><%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
>>
>><sql:setDataSource var="productDS"
>>       url="jdbc:postgresql://localhost:5432/recruitment"
>>       driver="org.postgresql.Driver"
>>       user="scott" password="" />
>>
>><%-- conditional logic and sql manipulation --%>
>><c:choose>
>>    <c:when test="${request.operation == 'Add'}">
>>            <sql:update>... sql tags to support the add request
>>    </c:when>
>><c:when test="${request.operation == 'Remove'}">
>>            <sql:update>... sql tags to support the remove request
>>    </c:when>
>>    <c:when test="${request.operation == 'Edit'}">
>>            <sql:update>... sql tags to support the edit request
>>    </c:when>
>></c:choose>
>>
>><%-- query to load the html page contents --%>
>><c:choose>
>>    <c:when test="${request.operation == 'Search'}">
>><%-- EXPAND YOUR QUERY WITH SEARCH TERMS HERE --%>
>><%--
>>             use some conditional logic on the request
>>             parameters to deside how the query should
>>             be augmented
>>        --%>
>>        <sql:query var="productQuery"  dataSource="${productDS}"  >
>>        ....
>></sql:query>
>>    </c:when>
>>    <c:otherwise>
>>    <sql:query var="productQuery"  dataSource="${productDS}"  >
>>        SELECT * FROM CD
>></sql:query>
>>    </c:otherwise>
>></c:choose>
>>
>><%-- page with forms to add/edit/remove the contents --%>
>><html>
>><head><title>CD Catalog List</title></head>
>><body>
>><h1> CD Catalog List </h1>
>>
>><form method=get>
>>      <TD><input type=text name=cdId value=""></TD>
>>      <TD><input type=text name=cdTitle value=""></TD>
>>      <TD><input type=text name=cdArtist value=""></TD>
>><TD><input type=text name=cdCountry value=""></TD>
>>      <TD><input type=text name=cdPrice value=""></TD>
>><TD><input type=submit name=operation value="Search"></TD>
>></form>
>>
>><TABLE border=1>
>>  <TR>
>>    <TH>ID</TH>
>>    <TH>CD Title</TH>
>>    <TH>Artist</TH>
>>    <TH>Country</TH>
>>    <TH>Price</TH>
>>    <TH colspan=2>Command</TH>
>>  </TR>
>>
>><c:forEach var="row" items="${productQuery.rows}">
>>  <TR>
>>    <form method=get>
>>      <TD><input type=text name=cdId value="<c:out
> 
> value='${row.ID}'/>"></TD>
> 
>>      <TD><input type=text name=cdTitle value="<c:out
> 
> value='${row.CDTITLE}'/>"></TD>
> 
>>      <TD><input type=text name=cdArtist value="<c:out
> 
> value='${row.ARTIST}'/>"></TD>
> 
>><TD><input type=text name=cdCountry value="<c:out
> 
> value='${row.COUNTRY}'/>"></TD>
> 
>>      <TD><input type=text name=cdPrice value="<c:out
> 
> value='${row.PRICE}'/>"></TD>
> 
>><TD><input type=submit name=operation value="Edit"></TD>
>>    </form>
>>    <TD>
>>    <form method=get>
>>   <input type=hidden name=cdId value="<c:out value='${row.ID}'/>">
>>     <input type=submit name=operation value="Remove">
>>    </form>
>>    </TD>
>>  </TR>
>></c:forEach>
>><TR><TD>Add new entry</TD></TR>
>><TR>
>>   <form method=get>
>>      <TD><input type=text name=cdId value="..."></TD>
>>      <TD><input type=text name=cdTitle value="..."></TD>
>>      <TD><input type=text name=cdArtist value="..."></TD>
>>      <TD><input type=text name=cdCountry value="..."></TD>
>>      <TD><input type=text name=cdPrice value="..."></TD>
>>      <TD colspan=2><input type=submit name=operation value="Add"></TD>
>></form>
>></TR>
>></TABLE>
>></body>
>></html>
>>
>>If you want to encapsulate the functions for adding/removing/editing
>>the content and not have them in this "View/Controller", you could
>>include them from separate JSP's or Servlets. or likewise submit the
>>forms directly to those JSP's or Servlets  and then redirect back to
>>this jsp once the work was done.
>>
>>
>>
>>It stays pretty independent and light without too much dependency on
>>any particular framework other than the JSP/JSTL tags. Which results in
>>less research and development effort  to accomplish the same task. All
>>you need to know is JSP/JSTL.
>>
>>
>>
>>-Mark
>>
>>
>>>
>>Eddie Barna wrote:
>>
>>
>>>You can pass the value from your search form to the page which you have
>>>listed in your email.  For example:  You have a search form with a text
> 
> box
> 
>>>titled search
>>>
>>>Here's what the page that queries the db would look like now
>>>
>>>
>>>
>>>
>>>><sql:query var="productQuery"  dataSource="${productDS}"  >
>>>>       SELECT * FROM CD WHERE CDTITLE = ?
>>>>
>>>>
>>>
>>><sql:param value="${param.search}"/>
>>>
>>>
>>>></sql:query>
>>>>
>>>>
>>>You can also expand on this by using the OR statement in your query.  For
>>>example:
>>>
>>>
>>>
>>>
>>>><sql:query var="productQuery"  dataSource="${productDS}"  >
>>>>       SELECT * FROM CD WHERE CDTITLE = ? OR ARTIST = ?
>>>>
>>>>
>>>
>>><sql:param value="${param.search}"/>
>>><sql:param value="${param.search}"/>
>>>
>>>
>>>></sql:query>
>>>>
>>>>
>>>For every condition in your query you must add a <sql;param/> tag.
>>>
>>>Hope this helps.  I really do recomend that you get Shawn Bayern's book
>>>titled JSTL in Action.  It explains all this in great detail, plus
>>>everything else.
>>>
>>>
>>>----- Original Message -----
>>>From: "Scott Taylor" <scott.taylor@4i-dotcom.com>
>>>To: <taglibs-user@jakarta.apache.org>
>>>Sent: Friday, February 14, 2003 9:31 AM
>>>Subject: Tag List
>>>
>>>
>>>
>>>
>>>
>>>>I am trying to find a list of tags to help me modify the CD Shop Cart
> 
> web
> 
>>>>application from Sun One.
>>>>
>>>>For example, how do I insert tags that provide a search form (and entry
>>>>form) rather than simply list everything.
>>>>
>>>>Here is what the code looks like so far:
>>>>
>>>><%@page contentType="text/html"%>
>>>><html>
>>>><head><title>CD Catalog List</title></head>
>>>><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
>>>><%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
>>>><body>
>>>><h1> CD Catalog List </h1>
>>>><sql:setDataSource var="productDS"
>>>>      url="jdbc:postgresql://localhost:5432/recruitment"
>>>>      driver="org.postgresql.Driver"
>>>>      user="scott" password="" />
>>>>
>>>><sql:query var="productQuery"  dataSource="${productDS}"  >
>>>>       SELECT * FROM CD
>>>></sql:query>
>>>>
>>>><TABLE border=1>
>>>> <TR>
>>>>   <TH>ID</TH>
>>>>   <TH>CD Title</TH>
>>>>   <TH>Artist</TH>
>>>>   <TH>Country</TH>
>>>>   <TH>Price</TH>
>>>> </TR>
>>>>
>>>><c:forEach var="row" items="${productQuery.rows}">
>>>> <TR>
>>>>   <TD><c:out value="${row.ID}"/></TD>
>>>>   <TD><c:out value="${row.CDTITLE}"/></TD>
>>>>   <TD><c:out value="${row.ARTIST}"/></TD>
>>>>   <TD><c:out value="${row.COUNTRY}"/></TD>
>>>>   <TD><c:out value="${row.PRICE}"/></TD>
>>>>   <TD>
>>>>   <form method=get action="ShopCart.jsp">
>>>>     <input type=hidden name=cdId value="<c:out value="${row.ID}"/>">
>>>>     <input type=hidden name=cdTitle value="<c:out
>>>>value="${row.CDTITLE}"/>">
>>>>     <input type=hidden name=cdPrice value="<c:out
>>>>
>>>>
>>>
>>>value="${row.PRICE}"/>">
>>>
>>>
>>>>     <input type=submit name=operation value=Add>
>>>>   </form>
>>>>   </TD>
>>>> </TR>
>>>></c:forEach>
>>>></TABLE>
>>>></body>
>>>></html>
>>>>
>>>>Regards
>>>>
>>>>Scott
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>>
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>>
>>>
>>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 


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


Mime
View raw message