Louis wrote:

> hi,
>    I just try to understand Custom Tag. One of the advantage of Custom tag
> is minimize the java code in JSP.  Follow the model 2,  the business logic
> is not in the JSP, so i.e java code is very few in the JSP page.  So is that
> means Custom tag is only useful for model 1 application?
>

Not necessarily.

One of the many things you can do with custom tags is generate complex HTML output
based on what that tag knows about the page plus a few simple attributes.  For
example, in the Struts framework (a basic framework for model 2 apps available at
<http://jakarta.apache.org/struts> there is a "text" tag that lets you say this in
your page:

    <struts:text property="username"/>

and have it behave like you said this instead:

    <input type="text" name="username" value="<%=
BeanUtils.filter(someBean.getUsername()) %>">

In the future, we'll be adding the ability for this tag to generate some JavaScript
code to do simple clientside validations, as well.  Then you'll be able to say

    <struts:text property="username" validate="required"/>

and not have to know anything about JavaScript coding to get this client side
editing feature.

Struts has a comprehensive library of custom tags for building forms that interact
with JavaBeans on the server side in convenient ways -- but it is very much focused
on the MVC (model 2) design pattern.  And it represents only one of the kinds of
things that custom tags are useful for.

>
> Thanks
>
> Louis

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to