Perhaps something like this?
Not tested at all but I suppose it ought to work.
in your template:
<t:form>
<t:hidden value="hiddenValue"/>
<t:textfield value="textValue"/>
<script>
window.onload = function () {
alert('about to submit');
document.forms[0].firstChild.value = 'i just set the hidden value';
document.forms[0].submit();
};
</script>
</t:form>
in your class:
@Property
private String hiddenValue;
@Property
private String textValue;
void onSuccess()
{
System.out.println("Hidden value is: " + hiddenValue);
System.out.println(" Text value is: " + textValue);
}
If you find web development and javascript extremely hard and spend hours on
this with no result whatsoever, perhaps you could start with a basic simple
form (no js involved) and a single textfield? Once you get that working, you
could build the rest from there one step at a time.
If you then come across a problem, you could show us a *minimal* example that
describes this problem, and then explain:
- what are you trying to do?
- how did you try to implement that?
- what happened when you ran it?
- what did you expect would happen?
People around here are very helpful if you only present them with a specific
question rather than ask for a complete solution.
Or, if you wish, you could refer me to some example code somewhere in the
Tapestry documentation that does this. It must be a very common
requirement.
Have you checked the tutorial?
http://tapestry.apache.org/tapestry5/tutorial1/
There's a specific chapter for forms:
http://tapestry.apache.org/tapestry5/tutorial1/forms.html
Martin
On Wed, 14 Oct 2009 21:07:54 +0200, Lindsay Ridgeway <lindsay.ridge...@mac.com>
wrote:
Hi, Martin. Thanks for your response. Unfortunately, I still feel lost.
(Let me say that I have programmed computers every day for over 40 years and
have spent the last three days totally immersed in Tapestry documentation
and a large existing Tapestry code base that doesn't happen to have an
example of this requirement. I have tried dozens of experiments to meet
this requirement. So I don't feel my being lost is from a lack of effort or
background.)
I realize that to a more experience T5 person, what you sent would no doubt
be sufficient, but it's missing too much information for me to understand
how to code what I need. I still don't understand how to code the t:form
element so that the JavaScript code can refer to it, how to code the
t:hidden element so that it matches up with something in the Java code, how
to code the JavaScript code to store a value in the hidden field, how to
code the JavaScript submit statement, and how to access the form data when
the method gets called.
If you don't have time for my original request, here's a simpler one.
I would really appreciate it if you would take a few moments to write out:
* One little example form with a textfield element in it and a hidden field
in it -- please include the entire form, from t:form to the end tag
* One little example JavaScript function that fills in the hidden field and
submits the form
* One little example fragment of Java code that uses System.out.println() to
send the textfield value and the hidden field value to the console.
I think this would be maybe 10 or 15 lines of code tops, and it would really
help me instead of trying to spend several more hours trying to figure out
the missing pieces from the information you already sent.
Or, if you wish, you could refer me to some example code somewhere in the
Tapestry documentation that does this. It must be a very common
requirement.
Thanks again!
--Lindsay
I'd also like to have multiple Java methods that receive control depending
on which submit button is clicked.
You can accomplish this with the Submit component . . .
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org