RE: multiple checkboxes (was: Radio Button Example using boolean?)

2001-07-12 Thread Tim Colson

Suhas -

 I already posted a answer to Q like this [using radio buttons]
Yes indeed - many thanks for that!!!  :-)

It was quite helpful - a lot of folks answer with partial snippets, but
don't cover all that is necessary to make the thing work. Even the example
apps (which are the model I've been following for much help) sometimes make
it difficult to apply when for example, the multi-select is populated by a
page-context scriptlet instead of the Action...or should it come from the
formand then how does the syntax of the tag change... etc. etc.

Unfortunately, these details which may be obvious to those experienced with
the framework - cause headaches for those of us who are just starting out.

Struts has been a bit complicated to get started with. Code has to be
written in 4 or more places (struts-config, action class, form class, view
JSP, model bean, view bean).

It's all starting to make sense - but it's a _tremendous_ help to see
complete examples with all the details included.

Thanks again!
Timothy




Re: Radio Button Example using boolean?

2001-07-11 Thread suhas

Do something like this
in strtus-config.xml file -

  !-- Do nut --
  action path=/donut
 type=example.DoNutAction
 name=doNutForm
   forward name=success  path=/donut.jsp/
  /action

In the donut.jsp -
%@ taglib uri=/WEB-INF/struts-logic.tld prefix=logic %
%@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
%@ taglib uri=/WEB-INF/struts-html.tld prefix=html %
html:html
html:form action=/donut.do
html:radio property=donut value=true 
 bean:message key=yes /
/html:radio
html:radio property=donut value=false /
 bean:message key=no /
/html:radio
html:submit
bean:message key=button.submit /
/html:submit
/html:form
/html:html

In the DoNutForm.java

package example;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class DoNutForm extends ActionForm {
 private boolean donut;
 public DoNutForm() {
 }
 public void reset(ActionMapping mapping , HttpServletRequest req) {
  donut = true;
 }
 public void setDonut(boolean  donut) {
  System.out.println( **in the setter donut** + donut);
  this.donut  = donut ;
 }
 public boolean getDonut() {
  System.out.println( in the getter + donut);
  return donut;
 }
}

In the DoNutAction.java
public final class DoNutAction extends Action {
   public ActionForward perform(ActionMapping mapping,
   ActionForm form,
   HttpServletRequest request,
   HttpServletResponse response)
   throws IOException, ServletException {
  return mapping.findForward(success);

 }
}




- Original Message -
From: Tim Colson [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 11, 2001 5:54 AM
Subject: Radio Button Example using boolean?


 Does someone have a simple example of using two radio buttons (YES / NO)?

 Can they be populated from a boolean in the form?

  input type=radio name=LIKES_DONUTS value=YES checked Yes
  input type=radio name=LIKES_DONUTS value=NONo

 Side Question: What's the pro/con of simply using the standard HTML
elements
 with some logic: tags to do this?

 Thanks,
 Tim