Hi, I will look at the code a bit later, but could you try contrib:FormTable rather than contrib:Table? That will submit the form when the table is sorted or when the page is changed and the values will be submitted as a result. At the moment they (the current state of the checkboxes, etc) would be lost without a submit.
----- Original Message ----- From: "Sebastian Knoerzer" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, April 11, 2005 6:51 PM Subject: contrib:Table with Checkbox does not store data > hi all, > > i need two checkboxes in each row of a table. so thats no problem at all, but if > i sort the table all the selected checkboxes are unset. i also have a textfield > in each row and if i enter some text in the field, it will stay like it should. > > does anybody know how i can store the state of the boxes? > > i have tried to code my own checkbox component because i need to pass a short > value and not a boolean one. if the short value is 1 it should set the box to > selected and if the value is 0 it should set false. > > > heres the code (bad code). some lines are from the textfield component. > > public abstract class SbbsWebCheckbox extends Checkbox { > > public abstract IBinding getValueBinding(); > > public String readValue() { > Short value = (Short) getValueBinding().getObject("value", Short.class); > if (value != null) > System.out.println("###############READValue " + value.shortValue()); > else > System.out.println("###############READValue 00000000000000000" ); > if (value == null) > return "0"; > else > return value.toString() ; > } > > public void updateValue(String value) { > getValueBinding().setObject(value); > System.out.println("#UPDATEVALUE#######################VALUE " + value); > if (value.equals("0")) { > setSelected(false); > } > else if (value.equals("1")) { > setSelected(true); > } > else if (value.equals("on")) { > setSelected(true); > } > } > > > > protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { > String value; > IForm form = getForm(cycle); > boolean rewinding = form.isRewinding(); > > // If the cycle is rewinding, but the form containing this field is not, > // then there's no point in doing more work. > if (!rewinding && cycle.isRewinding()) > return; > > // Used whether rewinding or not. > String name = form.getElementId(this); > > if (rewinding) { > String param = cycle.getRequestContext().getParameter(name); > System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXX param " + param); > try { > value = param; > if (value != null) > updateValue(value); > return; > } > catch (Exception e) { > } > } > > writer.beginEmpty("input"); > writer.attribute("type", "checkbox"); > > writer.attribute("name", name); > > if (isDisabled()) > writer.attribute("disabled", "disabled"); > > value = readValue(); > System.out.println("RENDER#################### " + value); > if (value != null) { > updateValue(value); > } > > if (isSelected()) > writer.attribute("checked", "checked"); > > renderInformalParameters(writer, cycle); > > writer.closeTag(); > } > > > /*public abstract void setValue(Short value); > > public abstract Short getValue(); > */ > > protected void beforeCloseTag(IMarkupWriter writer, IRequestCycle cycle) { > // Do nothing. > } > > > the .page file: (only the important part) > ....... > ....... > <parameter name="selected" > type="boolean" > required="yes" > direction="form"> > <description> > The property read and updated by the Checkbox. > </description> > </parameter> > > <parameter name="value" type="java.lang.Short" required="yes" direction="form"/> > > <parameter name="disabled" type="boolean" direction="in"> > <description> > If true, then the checkbox will be disabled and any input from the checkbox > will be ignored. > </description> > </parameter> > > <reserved-parameter name="type"/> > <reserved-parameter name="checked"/> > <reserved-parameter name="name"/> > <reserved-parameter name="value"/> > > <property-specification name="name" type="java.lang.String"/> > <property-specification name="form" type="org.apache.tapestry.IForm"/> > > > > > thanks for your help!! > > regards > > sebastian > > > --------------------------------------------------------------------- > 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]
