Re: [Newbie] Direct action woes
Re: [Newbie] Direct action woes
- Subject: Re: [Newbie] Direct action woes
- From: Dirk Bajohr <email@hidden>
- Date: Fri, 16 Jul 2004 13:02:36 +0200
Hi,
when you submit a form all form data will be sent to the server either
by the url (GET) or by request data (POST).No matter which one you
choose you can access the posted values in your direct action class
with request().stringFormValueForKey("the_name"). You don't need to add
the form values to the submit button / form action, It's added
automatically.
Something interesting to read:
http://www.cs.tut.fi/~jkorpela/forms/methods.html#fund:
If the processing of a form is idempotent (i.e. it has no lasting
observable effect on the state of the world), then the form method
should be GET. Many database searches have no visible side-effects and
make ideal applications of query forms.
If the service associated with the processing of a form has side
effects (for example, modification of a database or subscription to a
service), the method should be POST.
Hope that helps.
Cheers,
Dirk
Am 16.07.2004 um 12:38 schrieb Amorya North:
Damnit, I feel stupid...
What I'm doing appears to be impossible, because I wanted something
added on to the form submit URL depending on the menu item selected.
And of course, the form URL is already written to the HTML by the time
the user gets a selectable menu, so there's nothing it can do to add
the URL!
Sorry to waste your time
Amorya
(now off to rethink how my app will work!)
On 16 Jul 2004, at 1:33 am, Amorya North wrote:
Am trying to have a play with the Direct Action stuff...
Firstly, all these sites giving helpful code neglected to tell me to
put the action in the Direct Action class file! It took me hours to
figure that one out :)
Anyway, I've got an action. Doesn't do much 'cos I'm just testing it.
It's called listFicsAction(). All it does so far is send the user to
listFiction.wo.
BUT - I want something to be passed in the URL.
On Main, I have a form which is nicely populated with a list of Genres
from my database. There's a popup menu with the Genres, and a submit
button.
I added a binding of ?genreID to the submit button. Then I made a
method called genreID() with the following code:
public Integer genreID() throws java.lang.NullPointerException {
try {
NSDictionary primaryKey =
EOUtilities.primaryKeyForObject(selectedGenre.editingContext(),
selectedGenre);
return (Integer) primaryKey.valueForKey("genreID");
} catch (java.lang.NullPointerException exception) {
Integer a = new Integer(0);
return a;
}
}
(Yes, the catching exception thing took me ages to figure out too!) I
then bound that method to the binding ?genreID that I'd just created
in
the submit button.
Well, I compile at that point, and clicking the submit button goes
back
to main. It turns out I have to have the direct action method bound in
the WOForm's DirectAction binding too, not just in the submit button.
(That confused me 'cos when doing normal actions, you don't have to
touch the form.)
Anyhow, I now have it going to the new page, but it doesn't put the
genre ID in the URL! I was told that if I had a binding starting with
a
question mark, it automatically got shoved in the URL.
Before anyone says anything, I know I don't have any code to get it
out
of the URL at the other end. I've not got to that yet. I want my form
to put it in there!
Amorya
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
--
Dirk Bajohr
iSOLUTION - Individuelle Software fuer moderne Kommunikation
Hauptstr. 50
53757 Sankt Augustin
T +49 2241 921567-0
F +49 2241 921567-89
http://www.isolution.de
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.