Sure. Here's a piece of what I'm in the middle of trying to update right
now. It started out using the "jsp:useBean" tag followed by the
"jsp:getProperty" tags. One of the limitations (probably due to my own
ignorance) I ran into was some way of writing the options for a select tag
that would "select" the appropriate option corresponding to the value found
in the database. Note in the "source" select tag below, I simply wrote a
function in my bean that would iterate all of the options in the bean while
building a string containing all the necessary HTML code.

Contrast that with "link_type" options that I built this afternoon where I'm
using JSTL to iterate a collection of very simple objects. Here all of the
HTML code is on the JSP page.

I guess what I mean by "using beans vs. using JSTL tags" has to do more with
how I get the data onto the page. For example, on this page I can write the
"sourceUrl" value by either...

<c:out value="${dumfriesArticle.sourceUrl}" />
    ...or...
<jsp:getProperty name="dumfriesArticle" property="sourceUrl" />

Right now I'm inclined to be consistent (as consistently as I can) and since
I like using the <c:forEach approach to building the "option" elements for
my "select" tag I'm inclined to use the <c: set of tags throughout and just
get rid of the <jsp: tags.

Anyway, that's enough rambling for one post. Thanks for responding! Here's
my code sample...

<%@ page import = "com.dumfries.utilities.*, java.util.ArrayList,
java.util.Iterator, java.util.Collections"%>
<%@ taglib prefix="c" uri="/WEB-INF/lib/c.tld" %>
<jsp:useBean id="dumfriesArticle" scope="request"
type="com.dumfries.utilities.ArticleForm" />


<form name="article_detail" method="post" action="updatearticle">
<table border="1" width="100%" cellspacing="0" cellpadding="4">
   <tr>
      <td align="right"><p class="f">ID:</td>
      <td><jsp:getProperty name="dumfriesArticle" property="articleKey"
/></td>
   <input type="hidden" name="article_id" value="<jsp:getProperty
name="dumfriesArticle" property="articleKey" />">
   </tr>
   <tr>
      <td align="right"><p class="f">Title:</td>
      <td><textarea cols="75" name="title" rows="3"
wrap="soft"><jsp:getProperty name="dumfriesArticle" property="title"
/></textarea></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Subtitle:</td>
      <td><textarea name="subtitle" cols="75" rows="3"
wrap="soft"><jsp:getProperty name="dumfriesArticle" property="subtitle"
/></textarea></td>
   </tr>
   <tr>
      <td align="right"><p class="f">Byline:</td>
      <td><textarea name="byline" cols="75" rows="3"
wrap="soft"><jsp:getProperty name="dumfriesArticle" property="byline"
/></textarea></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Article Date:</td>
      <td><input type="text" name="article_date" size="10"
value="<jsp:getProperty name="dumfriesArticle" property="articleDate"
/>"></td>
   </tr>

   <tr>
      <td align="right"><p class="f">source:</td>
      <td>
<jsp:getProperty name="dumfriesArticle" property="articleSource" />
      </td>
   </tr>


   <tr>
      <td align="right"><p class="f">Body:</td>
      <td><textarea name="body" cols="75" rows="20"><jsp:getProperty
name="dumfriesArticle" property="body" /></textarea></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Formatted:</td>
      <td><input type="checkbox" name="formatted"
value="true"<jsp:getProperty name="dumfriesArticle"
property="formattedCheckboxState" />></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Publish:</td>
      <td><input type="checkbox" name="publish" value="true"<jsp:getProperty
name="dumfriesArticle" property="publishCheckboxState" />></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Article Type:</td>
      <td>
<jsp:getProperty name="dumfriesArticle" property="articleType" />
      </td>
   </tr>

   <tr>
      <td align="right"><p class="f">Link Type:</td>
      <td>
<select name="link_type" class="f">
<c:forEach var="lto" items="${LinkTypeOptions}">
 <option value="<c:out value="${lto.value}" />"<c:if
test="${lto.value==dumfriesArticle.linkTypeSelection}">
selected</c:if>><c:out value="${lto.text}" /></option>
</c:forEach>
</select>
      </td>
   </tr>

   <tr>
      <td align="right"><p class="f">Source URL:</td>
      <td><input type="text" name="source_url" size="50" value="<c:out
value="${dumfriesArticle.sourceUrl}" />"></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Alt URL:</td>
      <td><input type="text" name="alt_url" size="50" value="<c:out
value="${dumfriesArticle.altUrl}" />"></td>
   </tr>

   <tr>
      <td align="right"><p class="f">Created Date/Time:</td>
      <td><jsp:getProperty name="dumfriesArticle" property="createdDatetime"
/></td>
   </tr>



----- Original Message ----- 
From: "Martin Cooper" <[EMAIL PROTECTED]>
To: "Tag Libraries Users List" <[EMAIL PROTECTED]>
Sent: Sunday, April 11, 2004 2:43 PM
Subject: RE: JSTL Tags Vs. JavaBeans


>
>
> > -----Original Message-----
> > From: Jeff Brewer [mailto:[EMAIL PROTECTED]
> > Sent: Sunday, April 11, 2004 11:27 AM
> > To: [EMAIL PROTECTED]
> > Subject: JSTL Tags Vs. JavaBeans
> >
> >
> > In the process of trying to get my site up and running I came
> > across a page that I'd written a year ago (not a big site--just a
> > slow programmer) before I learned about JSTL that uses JavaBeans,
> > which led me to ask the question "Should I redo this page using
> > JSTL tags?"
> >
> > What's the current "State of the (JSP) Art" with respect to JSTL
> > vs. JavaBeans? Is one preferred over the other?
>
> I'm not sure what you mean. JSTL can use and manipulate JavaBeans -
they're
> complimentary technologies, rather than alternatives. Perhaps if you could
> describe a little about what your page is doing, or even provide a piece
of
> it for us to look at, we'd be able to better help you decide on the best
> approach.
>
> --
> Martin Cooper
>
>
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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