Hi,
I am sorry to disturb you but i have a matter. In fact, i load my combobox using “.load(action.do)”. Thanks to struts, i make an xml page loading data which comes from a database. However, there is the possibility that i want to send an error using an alert. I put this error in the request (“request.setAttribute(“err”,error);”) and i make struts send back to a false page. So, it will create an loadXML event. When i try to show the error which is in the request using :
function erreurCB(type, name, data) {
if (type == “LoadXML”)
{
var backError = ‘<%=request.getAttribute(“err”)%>’;
alert(backError );
}
}
dhtmlxError.catchError(“LoadXML”, erreurCB);
It shows me : null .
Please, do you know a way in order to resolve this matter ?
Hi,
does this issue relate to dhtmlxcombo ? or it is the problem in your application…
I think the problem is that i don’t know how to recover and to show the message that i have put into the request.
In an jsp page (java server page), you can recover an object from the request using :
<%=request.getAttribute(“err”)%>
However, when i recover the object “err” which is a String (a text) and i put it into an alert, it displays : “null” .
Can i put the message into the xml file that i use in order to load the data into my combobox ? If i do it, how can i recover this message into the dhtmlxError ?
NB: I have tried to put the message in the session and to recover it but since i don’t reload the page, it does’nt work.
the 3rd parameter of error handler is array those first element is xmlDoc object. Therefore, you may get data which are returned from server in this xml.
For example, if the xml contains “An error has occured!!” text, the following approach can be used to get this message:
function your_error_handler(type, name, data){
if(type=="LoadXML")
alert(data[0].responseText);
}
dhtmlxError.catchError("LoadXML",your_error_handler);
I have resolved the matter. I load a xml where the text is null and the value is the error message.
Then :
comboDir.loadXML("action.do?categorie=B&action=ve&code="+codeDir+"&type=DIR",
function ifErreurDir(){
if( null == comboDir.getSelectedText() || "" == comboDir.getSelectedText()){
alert(comboDir.getSelectedValue());
comboDir.loadXML("actionReload.do");
});
So, i look at if this is an error which comes back (using the “if” function on the selectedText of the comboBox). In this case, i retrieve the error message that i have put in the value of the comboBox. To finish, I create an alert with this value and i reload the comboBox with other data using an other action.
Thanks you for your help