Mohan Radhakrishnan <[EMAIL PROTECTED]> wrote:
> I have several radio buttons in the form. How do I pass
> all the boolean values based on the checked property of
> the buttons to the JSP page?
> There may be several buttons. Is there a way to do this
> with a bean ?
I use the setProperty directive, like:
<jsp:setProperty name="pizza" property="*"/>
in conjunction with the name in the RADIO input type:
<% for(i=0; i<pizza.getOptionCount(); i++) { %>
<INPUT TYPE=radio NAME=product
<%= ((i==0) ? "CHECKED" : "") %>
VALUE=<%= "\"" + pizza.getToppingName(i) + "\"" %>
>
<%= pizza.getToppingName(i) %>
<% } %>
When the JSP page is reloaded (I use the same JSP to generate display, order
and collection HTML code) there is a "product" property with a value of
something like "pepperoni". One of the first things that gets executed is
the setProperty directive. This directive causes the bean associated with
the pizza variable to get inspected to look for a setProduct method as well
as a product attribute and a getProduct method. If found, the setProduct
method is executed with the VALUE part passed as a parameter. Since you will
have several radio input types you will need to have them named differently
and have each associated with a different set/get/attribute name in your
bean.
Tom Ekberg, [EMAIL PROTECTED]
Coyote Technologies, LLC
972-889-5212
===========================================================================
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