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
-- 
View this message in context: 
http://www.nabble.com/Tapestry-5-Submit-Form-from-Javascript-tp25895341p25900642.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to