I know that the Java pros believe in keeping Java out of JSP, and do so
by using taglibs and beans.

The only real custom programming in my Magnolia-based site right now is
a pharmacy lookup script. To try to adhear to the taglib approach to
doing things, I utilize the SQL taglib, but fall back to using
scriptlets to capture form data, build a 'where clause', insert the
clause into the SQL string, and fix any number signs in the address so I
can get a map.

I know this isn't Magnolia, but with the holidays coming, perhaps
someone is feeling generous.

Is it possible to avoid using scriptlets in these situations completely?

Is it worth the trouble to build a class or bean or prepared statement
for such a simple little process?

How offensive is this mixture of methods to the pros with their OOP &
MVC & API's & frameworks?

I'm not asking anyone to build me a bean, but just a little direction.






<%@ taglib uri="cms-taglib" prefix="cms" %>
<%@ taglib uri="cms-util-taglib" prefix="cmsu" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql"; prefix="sql" %>
<%
String where = "";
String st = request.getParameter("st");
String zip = request.getParameter("zip");
String area = request.getParameter("area");
if (!zip.equals("")) {
  zip = zip.substring(0, 5);
  where = where + "SUBSTR(ZIP,1,5) = '"+ zip +"' AND ";
}
if (!st.equals("")) {
  where = where + "STATE = '"+ st +"' AND ";
}
if (!area.equals("")) {
  where = where + "AREACODE = '"+ area +"' AND ";
}
%>

<sql:query var="rs" dataSource="jdbc/sapdb">select store, addr1, city,
state, zip, areacode & '-' & phone1 phn, hours from UNITED.STORE_MEMBER
where <%= where %> "NON-PHARMACY" = 'N' and resigned = 'N' order by
store</sql:query>

<c:set var="rowcount"><c:out value="${rs.rowCount}"/></c:set>
<table width="100%" border="0" cellspacing="0" cellpadding="10">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <c:set var="class_subtitle"><cms:out
nodeDataName="class_subtitle"/></c:set>

        <c:if test="${rowcount=='0'}">
        <tr>
          <td class="${class_subtitle}">No Records Match Your
Criteria</td>
        </tr>
        </c:if>

        <c:if test="${rowcount!='0'}">
        <tr>
          <td colspan="4" class="${class_subtitle}"><cms:out
nodeDataName='subtitle'/></td>
        </tr>
        <tr>
          <td colspan="4">&nbsp;</td>
        </tr>
        <tr bgcolor="#003366">
          <td style="color: #FFFFFF" width="35%">Name</td>
          <td style="color: #FFFFFF" width="30%">Address</td>
          <td style="color: #FFFFFF" width="15%">Phone</td>
          <td style="color: #FFFFFF" width="20%">Hours</td>
        </tr>

        <c:forEach var="row" items="${rs.rows}">
        <c:set var="adr" scope="page"><c:out value='${row.addr1}'
/></c:set>
<%
 String adr = (String) pageContext.getAttribute("adr");
 adr = adr.replaceAll("#", "No");
%>
        <tr>
          <td>
<a
href="http://www.mapquest.com/maps/map.adp?country=US&countryid=US&addto
history=&searchtype=address&cat=&address=<%= adr %>&city=<c:out
value='${row.city}' />&state=<c:out value='${row.state}'
/>&zipcode=<c:out value='${row.zip}' />&search=  Search
&searchtab=address" target="_blank" title="Get A Map"><c:out
value='${row.store}' /></a>
          </td>
          <td><c:out value="${row.addr1}" /><br>
          <c:out value="${row.city}" />, <c:out value="${row.state}" />
<c:out value="${row.zip}" /></td>
          <td><c:out value="${row.phn}" /></td>
          <td><c:out value="${row.hours}" /></td>
        </tr>
        </c:forEach>
        </c:if>
        <tr>
          <td colspan="4">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="4"><input type="button" id="bt1"
onClick="location.href='../pharmacy_locator.html'" value="New
Search"/></td>
        </tr>
      </table>
    </td>
  </tr>
</table>


----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to