Greetings all,
Welcome to the new year!
see http://www.purplelizardgallery.com/gato_edit.jsp
Thanks to the help I've received in this forum I've got my Dojo-enabled page and servlet talking to one another BUT only under certain circumstances:
a) button "send to server outside of form using params" triggers a JS function that packages up the forms' fields in a JS variable named params then applies this variable to the content: attribute of xhrPost. this works as you can see the fields' values reflected back from the server.
b) button "send to server outside of form using form" triggers a JS function that applies the form id to the form: attribute of xhrPost. This doesn't work correctly as only NULL values come back from the server.
c) button "Update Project" located within the form triggers the same function as b). This button is of type="submit" and in intercepted by the execute= parameter of the form declaration statement. Not only does this not work, but the page refreshes so I can't see what comes back from the server and not even the console statements show up in Firebug.
I'd like to get c) working and also learn how to disable the refreshing of the page that the form-submittal seems to trigger. Googling points to using e.preventDefault() to achieve this but I couldn't figure out how to make it work for me.
Any hints/suggestions/positive comments and of course examples are always appreciated!
TIA,
Still-learning Stuart
PS - signing off now for the next 8hrs, will check back then.

RE: xhrPost, form: parameter and execute attribute not playing..
Hi,
- 1... is there any reason to NOT use dijit for "all" your widgets? (for example the select and the buttons "out side the form");
- 2... Why some of your widgets are "out of the form" ? for example... "select" if u wanna make it "required"... why not use a "filtering select" and make it so... (that way the user will have to choose a project)
- 3... If u wanna CONNECT widgets... why do that on form action.... u could do that at the widget it self.. (Like in the select u could put a action "onChange")?
- 4.... Why not feed "Select" by a datastore?
Plus... I only give a overview... but seens to me that u use 2 much js for a simple operation.... it might cause some unnecessery work and strange behavior...
another notice... if u will use xhrpost u simple feed the xhrpost with the form "id" no need to pass the values as parameter (unless u wanna treat multiple choices on the form processing)...
Another thing... instead only say what u do... u could describe the desired behavior of ur app (not details but just what u wanna as "macro" transaction)...
PS: In the future... minimizing ur dojo would be nice!
I've implemented some of
I've implemented some of your suggestions, after discovering that forms' execute method is deprecated I've now switched to connecting to the form's onsubmit event.
http://www.purplelizardgallery.com/gato.jsp
As it is now here are lines 37 and 38:
[code]
// dojo.connect( dojo.byId('projBidForm'), "onsubmit", function(e){ e.preventDefault(); validateForm });
dojo.connect( dojo.byId('projBidForm'), "onsubmit", "validateForm" );
[/code]
with line 37 commented out, clicking the "Update" button on the Edit tab after selecting a project does run the updateProject function, so the xhrPost occurs, so the form is submitted, which causes the page to refresh, so I can't see what's received back from the server in the console log.
with line 37 active and line 38 commented out, clicking the "Update" button doesn't do anything at all. Argh!
Question: what must I do to submit the form IN THE BACKGROUND without causing a page-refresh? HELP!
Still-learning Stuart
Re: I've implemented some of
Hi,
About submit...
If u are doing XHRPOST (or GET) u DONT NEED to submit... U just call the XHRPOST onClick of ur button...
the: "http://www.purplelizardgallery.com/gato.jsp" is not online anymore... (HTTP Status 404 - /gato.jsp)
TO do the "post" with XHRPOST without submit... U do:
Create a function with all operations (validations... varifications and connections between objects..) and the xhrpost....
somethings like:
if ( dijit.byId('myForm').isValid() ) {
dijit.byId('txtCod').attr('value',SOME_FUNCTION_OR_VALUE_HERE); // OPTIONAL LOAD OF DATA ON FIELD or some extra checks
document.getElementById('txtCodPost').value = SOME_FUNCTION_OR_VALUE_HERE; // IF u still have NON-Dojo objects... u might do it on them as well
cod = dijit.byId('txtCod').attr('value');
// NOW LETS POST!
dojo.xhrPost({
url: 'application/controllers/myFormProcessor.jsp?debug=true&extra=yes', //U can post to a processor page and also passe parameters
form: dojo.byId('myForm'),
//handleAs:"text", //How u will treat the return (u can pass arrays or text ar return or ur process ) It mean that "myFormProcessor.jsp" will return in the choose format
handleAs:"json", //I prefer json
load: function(data){
if(data.items[0].value == 0) {
djAlerta(':: Warning!','No value processed for: '+cod); // djAlerta is my function to build dijit Dialog (I post it some where)
} else {
if(data.items[0].FIELD_FROM_JSON > 0 ){ //Insert ou append depends on a difined field on form
dijit.byId('txtOper').attr('value','A');
} else {
dijit.byId('txtOper').attr('value','I');
}
}
In a SIMPLES Dijit button... like:
Pseudo Submit