[Opensource] Réf. : [Opensource] HTML tags won't recognize ControllerElement Inputs

Raul DAVIDOVICH R.DAVIDOVICH at caconcology.com
Wed Aug 21 05:40:38 PDT 2002


Hello,


      I had some trouble with checkboxes too.. this is the solution I
found:


in the controller:

protected ControllerResponse runPromptTransitionState(ControllerRequest
params, ControllerResponse response) throws ControllerException{

. . .

Input myInput = new Input();
myInput.setName("MyInput");
myInput.setLabel("This is a CheckBox");
myInput.setType("checkbox");
myInput.addValidValue("true", "");   //here you give the value you want to
the checkbox (much more comfortable than the traditional "checked")...
"checked" = "true" "not checked" = null
response.add(myInput);    //it also works for a block


Transition nextTransition = new Transition("Next", getClass().getName());
nextTransition.setName("NextTransition");
nextTransition.addParam("state", "nextTransition");
nextTransition.addParam("next", params.getParameter("next"));
response.add(nextTransition);

response.setStyle("myJSP");

. . .

}

protected ControllerResponse runNextTransitionState(ControllerRequest
params, ControllerResponse response) throws ControllerException{

. . .

String myInputStr = params.getParameter("MyInput");

. . .

myDBObject.setField("myField", myInputStr);  // I overrided my setField()
method for this DBObject to process the string comming from the checkbox to
set false when it's null,

. . .

}

In the JSP:

<html:form action="/DAParController.do" method="POST" >

<table border="1" cellspacing="1" cellpadding="2" >

<tr bgcolor="#E0E0FF" >
     <td>
      My Input :
     </td>
     <td>
      <expresso:InputTag name="MyInput"/>
     </td>
</tr>
<tr bgcolor="#E0E0FF" >
     <td>
      Command :
     </td>
     <td>
      <expresso:TransitionTag name="NextTransition"  />
      <html:reset/>
      <html:cancel/>
     </td>
</tr>
</table>

</html:form>




 Hope this helps



---------------------------------------------------
Raul Davidovich
Responsable Informatique
Cvitkovic & Associés Consultants

(33) 1 45 15 40 68
(33) 1 45 15 40 41 Fax
-------------------------------------------------------
http://www.caconcology.com


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I'm trying to generate a variable list of checkbox inputs, based on the
results of a SearchAndRetrieveList.  The problem: when I put Input objects
into a Block and try to access them directly through an <html:checkbox>
tag,  I receive the error message  that my Input objects are actually
Output objects.  Any idea what I'm doing wrong?





Additionally, I'd like to place the Inputs within a Block (or Blocks) and
dynamically create checkbox lists.  I've been working with this sample code
in my Controller, but have not been able to retrieve the Inputs as
checkboxes within JSP's.  (As my variable names reveal, I've been
consulting ControllerSecurityMatrix.java and a few other Expresso files,
but haven't had an ounce of luck assembling a working JSP.)





Input cb = null;


Block matrix = new Block("matrix");


response.add(matrix);


for (int fred = 1; fred<8; fred++) {


                cb = new Input();


                cb.setType("boolean");


                cb.setAttribute("checkbox","");


                cb.setName("myCheckbox_"+fred);


                matrix.add(cb);


}








Thanks in advance,


Wolf Thompson







More information about the Opensource mailing list