The Tapestry Checkbox component doesn't offer a way to do what you
want but it is possible to do it.  If you have multiple input fields
with the same name, the servlet spec says that you can call
request.getParameters("fieldName") and receive an array of strings.

So here's how I solved this:

Write some code that renders a plain <input type="checkbox"
name="myName" value="someValue"/> rather than using Tapestry Checkbox
component.  If you want to make it a component, one very similar to
existing Checkbox, then so much the better.

Now make another component called CheckboxGroup.  Include a listener
method which will get executed whenever the CheckboxGroup is rewound.
Your custom Checkbox component can check if the current Container is a
CheckboxGroup.  if it is, get the name from the CheckboxGroup.  Then,
in your Group listener, call getWebRequest().getParameters("myName")
to retrieve a String[] of values. Now, if necessary, convert the
string to an actual object.  Then assign the array to the appropriate
place. html would look something like this:

<span jwcid="@lib:CheckboxGroup" name="literal:someObject.someEntitySet" >
 <span jwcid="@lib:CustomCheckbox" value="ognl:someValue"/>
 <span jwcid="@lib:CustomCheckbox" value="ognl:someOtherValue"/>
</span>

Although in our case, we skipped the CustomCheckbox component
entirely.  We just pass a SelectionModel to the CheckboxGroup, and use
the label and value properties to render a checkbox from the render
method of the CheckboxGroup.  We can fetch the values during the
rewind method of the same component.  And some simple ognl
manipulations on the name parameter can allow you to assign the
resulting values to the named object/property.

Of course, I have no idea if any of this will work in Tap3, but in my
case, it was only a couple of hours in Tap4, mostly spent figuring out
what changes I needed to make to the contrib:MultiplePropertySelection
and contrib:CheckBoxMultiplePropertySelectionRenderer.  The code was
easy enough to understand and modify to my own needs.

--sam


On 9/6/06, Peter Dawn <[EMAIL PROTECTED]> wrote:
ok. the only other way for me to obtain a users selection would a
radio button. might try that.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to