* Naturally I'd have preferred to use "t:hidden" rather than "t:textfield"
for the hidden field.  Unfortunately, I get the error "Unable to resolve
'hidden' to a component class name."

I think Hidden was added in Tapestry 5.1 so if you're using 5.0 "hidden" won't 
be an existing component.


* I'm still not clear when to use "t:" and when not to.  For example, could
I have used "form" instead of "t:form"?  I don't know.

You need to use t:form if you want to use a Form component, i.e. if you need 
Tapestry to do anything with the form submission such as invoke your onSuccess 
method or similar. Tapestry then sets the action attribute automatically and 
also knows how to deal with any other components such as t:textfield or 
t:hidden that are inside the form.

Had you used <form ...> and <input...> Tapestry would simply have rendered the 
html as you wrote it but there would be no integration with your server side code and any 
submitted data would have been sent off to the far reaches of cyberspace. ;)
There are other ways to reference components without resorting to jsp-style 
<t:form> and you can read about that in the documentation if you're interested.

Martin

On Thu, 15 Oct 2009 02:11:27 +0200, Lindsay Ridgeway <lindsay.ridge...@mac.com> 
wrote:



Martin Strand-4 wrote:

Perhaps something like this?

Thanks for your reply, Martin.  I appreciate the time you put into it.

I've continued experimenting on my own.  Here's a generic version of what
I've come up with:

THE JAVASCRIPT

<script>
  function extraStep() {
    alert("ENTER extraStep");
    document.getElementById("hiddenFieldId").value = "Here's some text:
Yippee!";
    document.sampleFormId.submit();
  }
</script>


THE FORM

<t:form t:id="sampleFormId">
  Fill in this field:
  <t:textfield t:id="textFieldId" t:value="textFieldProperty"/>
  <t:textfield t:id="hiddenFieldId" t:value="hiddenFieldProperty"
style="display: none;"/>
  <br/>
  <input type="button" value="Click Here" onclick="extraStep();"/>
</t:form>


THE JAVA
   @Property
    private String textFieldProperty;
   @Property
    private String hiddenFieldProperty;
   public void onActionFromSampleFormId() {
        System.out.println("textFieldProperty=" + textFieldProperty);
        System.out.println("hiddenFieldProperty=" + hiddenFieldProperty);
    }


NOTES

* I am not working on a new project, I'm working on an existing code base.
I don't have the resources (chiefly, time) to set up test projects, so I
can't be sure I haven't made a typo in the code above.  But code analogous
to the example above is now working on my Mac under Firefox.

* In the example, I've called ID's "xxxId" and properties "xxxProperty".
That was just to make clear the role of each name in the sample code.
Unlike various other T5 naming conventions, the suffixes "id" and "property"
have no special meaning to T5.

* I used "document.getElementById()".  That doesn't work on old IE and
Netscape browsers, but what the heck.

* Naturally I'd have preferred to use "t:hidden" rather than "t:textfield"
for the hidden field.  Unfortunately, I get the error "Unable to resolve
'hidden' to a component class name."  So I used the ugly alternative:
"t:textfield" with the parameter:

  style="display: none;"

* I'm still not clear when to use "t:" and when not to.  For example, could
I have used "form" instead of "t:form"?  I don't know.

Anyway, this code works, in case anyone else ever needs to do something
along these lines.  Thanks for everyone's help.

--Lindsay

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to