Open GoogleCodeExporter opened 9 years ago
The AJAX Request is bound to the target element. Without the Target Element the
Request is never submitted and the topics are not called.
Original comment by johgep
on 25 Apr 2013 at 7:38
In my case I do not have a target element. I mean the onCompleteTopics takes
care of showing the effect of the submit action, there is no target element to
directly affect. Work around I have used is to give it a dummy target element
that does not exist. In my opinion this could be a use case for a lot of
people, the target elements requirement to execute the topics should be removed.
Original comment by ashishga...@gmail.com
on 28 Apr 2013 at 6:09
I have the same issue and used exactly a dummy target!
------------------------------------------------
I am going to explain my problem and hope it would be useful for some one :)
Here is my problem:
1- If user submits a form the server may return an error or not.
2- I want to show the error on the same form.
My dummy element was actually a hidden div.
I developed and interceptor so the server always return the errors in JSON
format, so if there is an error the result could be parsed with JSON. (This
logic can be changed, for example you can return a simple fixed text and return
it to client)
All forms will have a form-error div, which will be used to show form errors.
The interceptor is a try catch which will be as below
try {
return invocation.invoke();
} catch (Throwable ex) {
response.setCharacterEncoding("UTF-8");
StringBuilder sb = new StringBuilder();
sb.append("{\"globalerror\":\" ");
sb.append(ex.getLocalizedMessage());
sb.append("\"}");
response.getWriter().write(sb.toString());
return Action.NONE;
}
The jsp:
onSuccessTopics="formServerErrorAnalyze"
The js:
$.subscribe("formServerErrorAnalyze", function(event, data) {
var recviedRequest = event.originalEvent.data;
var errorMessage;
try {
//if the form has errors then it will be type of json
errorMessage = $.parseJSON(recviedRequest);
$("#form-error").html(errorMessage .globalerror);
} catch (e) {
errorMessage="";
}
if (errorMessage===""){
// There is no error put the content of 'dummy' node to 'content'
var working = $("#dummy").contents();
var ref = $("#content").contents();
$("#dummy").append(ref);
$("#content").append(working);
}
//clean dummy
$("#dummy").html('');
});
Original comment by afattah...@gmail.com
on 10 May 2014 at 6:12
Original issue reported on code.google.com by
ashishga...@gmail.com
on 19 Apr 2013 at 11:32