Hello,
I think figured out my problem - I needed to render the html
template in rewindFormComponent! It was right in front of me the
entire time.
-Ryan
On Jun 3, 2006, at 3:40 PM, Ryan Cuprak wrote:
I think I follow. So you only display the TextField if the
checkbox was checked (via refresh submit)?
I plowed ahead with trying to implement my own
AbstractFormComponent that would use an html template and also
render some of its own content. However, I am getting a stale link
exception when I submit. Either I am setting something up
incorrectly or missing the boat on the rewind. Not exactly sure how
to parse the StaleLink page. Been diving through the list archives
and source trying to get a better idea on how component ids are
generated and the rewind is done.
I can create a new form component re-using other form components -
right?
To read the template I yanked code out of the BaseComponent class.
In the end, I want my custom component to display a checkbox and a
textfield (possibly a PropertySelection as well). When the form is
submitted, if the checkbox is checked but no content is contained
in the textfield I want to decorate it and add a message to the
top. This component will be used at least a dozen time on the page
for different search parameters.
Gradually learning!
Thanks,
Ryan
Exception:
---
You have clicked on a stale link.
Rewind of form test/testForm expected 1 more form elements,
starting with id 'selected'.
This is most likely the result of using your browser's back button,
but can also be an application error.
Component Java code:
---
public abstract class ComboTest extends AbstractFormComponent
implements ITemplateComponent {
private static Logger logger = Logger.getLogger(ComboTest.class);
private static final int OUTER_INIT_SIZE = 5;
private IRender[] _outer;
private int _outerCount = 0;
public ComboTest() {
}
public abstract boolean isSelected();
public void readTemplate(IRequestCycle cycle, IPageLoader
loader) {
loader.loadTemplateForComponent(cycle,this);
}
protected void renderFormComponent(IMarkupWriter writer,
IRequestCycle cycle) {
logger.debug("being combotest render");
// this was an attempt to solve it, thought maybe it was
missing the id for this component (this didn't work.)
writer.begin("input");
writer.attribute("type","hidden");
writer.attribute("name",getName());
writer.attribute("id",getName());
writer.end();
for(int i =0; i < _outerCount; i++) {
_outer[i].render(writer,cycle);
}
logger.debug("end combotest render");
}
protected void rewindFormComponent(IMarkupWriter writer,
IRequestCycle cycle) {
logger.debug("combotest choosen: choosen: " +
cycle.getParameter(getName()));
}
public void finishLoad(IRequestCycle cycle , IPageLoader
loader , IComponentSpecification specification) {
logger.debug("finishing load");
readTemplate(cycle,loader);
super.finishLoad(cycle,loader,specification);
}
public void addOuter(IRender element) {
logger.debug("outer being rendered");
if(_outer == null) {
_outer = new IRender[OUTER_INIT_SIZE];
_outer[0] = element;
_outerCount = 1;
return;
}
if (_outerCount == _outer.length) {
IRender[] newOuter;
newOuter = new IRender[_outer.length*2];
System.arraycopy(_outer,0,newOuter,0,_outerCount);
_outer = newOuter;
}
_outer[_outerCount++] = element;
}
}
HTML Template:
---
<html>
<head >
<title>Test</title>
</head>
<body jwcid="$content$">
<input type="checkbox" jwcid="selected"/>
</body>
</html>
Template:
---
<component-specification
class="com.kodak.mis.web.components.ComboTest"
allow-informal-parameters="yes"
allow-body="no">
<component id="selected" type="Checkbox">
<binding name="value" value="selected"/>
</component>
</component-specification>
On Friday, June 02, 2006, at 12:38PM, Mark Stang
<[EMAIL PROTECTED]> wrote:
What we do is to wrap the checkbox in an AnySubmit. And then when
checked a submit happens and the field is then displayed with
whatever mark-up is required. If the user attempts to leave the
screen standard edits tell them they need to provide a value. If
they uncheck the box, the field goes away. Basically, it is done
via a Conditional or Choose Component.
hth,
Mark
-----Original Message-----
From: Ryan Cuprak [mailto:[EMAIL PROTECTED]
Sent: Fri 6/2/2006 12:38 PM
To: users@tapestry.apache.org
Subject: Custom component validation - two fields
Hello,
We are trying to implement a rather simple custom form component
for a search page and perform validation on it. The custom
component has a checkbox and a text field. If the checkbox is
checked then a value must be provided in the text field. If not,
the field must be decorated and a message displayed at the top of
the form (tie in with the delegate etc). What is the recommended
approach for implementing such component validation? Must we
extend AbstractFormComponent and implement the renderFormComponent
or is there a simpler approach? Is there a hybrid
AbstractFormComponent/BaseComponent we have missed somehow?
Thanks!
Ryan
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
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]