tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: JSTL/JSP/regexp Question
Date Wed, 01 Dec 2004 17:30:04 GMT
Ideally you'd be using tomcat5. (and jdk1.4) Then you can use JSTL functions 
like below ...

<function>
   <name>match</name>
   <function-class>my.Foo</function-class>
   <function-signature>boolean match(java.lang.String,
                                     java.lang.String)
   </function-signature>
   <example>
     <c:if test='${fn:match("more", "r.")}'>
   </example>
</function>

------
package my;
public class Foo {
    public static boolean match(String s, String regex) {
        return s.matches(regex);
    }
}


-Tim

Jack Lauman wrote:

> I'm using the following code to return results from drop down menues and 
> user input text.
> It works fine as long as the text is an exact case sensitive match to 
> the data record.
> 
> What I want to do is evaluate the output the results of a user input 
> search based on
> 'param.field' in figure 3.  i.e. If 'param.field' = 'name' use a regex 
> or some other method
> to return all records  that are a partial, case insensitive match to the 
> input 'value' that
> was submitted in the search request.  Is this possible to accomplish in 
> JSTL?  If so I'd
> like to know how.
> 
> Thanks,
> 
> Jack
> 
> 
> Example1:
> JavaScript Funciton:
> 
> function MM_jumpMenu(targ,selObj,restore, field){ //v3.0
> eval(targ+".location='http://mydomain.com/filter.jsp?field="+field+"&value="+selObj.

> options[selObj.selectedIndex].value+"'");
> if (restore) selObj.selectedIndex=0;
> }
> //-->
> </script>
> 
> 
> Example 2:
> Form to submit the input and the field 'name' to be found in the bean 
> created array:
> 
> <form name="selectName" method="get" action="http:mydomain.com/filter.jsp">
> <input type="hidden" name="field" value="name">
> <input type="text" name="value" size="16" maxlength="40" value="">
> <input type="image" border="0" alt="Go!" src="images/go.gif" 
> align="absmiddle" width="22" height="23"  
> onChange="MM_jumpMenu('parent',this,0,'name')">
> <nwc:filterOptions which="name"/>
> </form>
> 
> 
> Example 3:
> Display the results.  JSTL gets the results form a Map/Array of the 
> entire record set that the bean
> created.  (restaurant.id is the PK)
> 
> <c:forEach items="${restaurantInfo.restaurants}" var="restaurant">
> <c:set target="${restaurant}" property="filterField" 
> value="${param.field}"/>
> <c:if test="${restaurant.filterValue eq param.value}">
> <tr>
> <td width="155" align="center">
> <div align="left"><a 
> href="http://mydomain.com/viewRestaurant.jsp?id=<c:out 
> value="${restaurant.id}"/>"><c:out value="${restaurant.name}"/></a></div>
> </td>
> <td width="130">
> <div align="left"><c:out value="${restaurant.address1}"/></div>
> </td>
> <td width="79">
> <div align="left"><c:out value="${restaurant.city}"/></div>
> </td>
> <td width="107">
> <div align="right"><c:out value="${restaurant.reservationPhone}"/></div>
> </td>
> </tr>
> </c:if>
> </c:forEach>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 

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


Mime
View raw message