on 08-10-2011 8:45 AM
Hi,
I have an Input Field bound to an attribute of type date (defined in dictionary with representation as dd/MM/yyyy) in a table.
On Submit, this date format is validated by the framework and a standard error is thrown if the format is different from above.
Is there any way I can override this standard method and print a custom message along with performing some other tasks. I essentially want to retrieve the row index(es) of the concerned rows and use them for further processing.
Even if I can extract the row index(es) of the concerned rows somehow, it would solve my problem Giving a custom mesaage is not all that important.
SAP NetWeaver Developer Studio Version: 7.02.06
Thanks,
Himanshu
Hello Himashu,
Once the validation error happens, after exeucting BeforeAction method, the control goes to component's before navigation method. here you can check in message manager whether it has validation errors. if so then you can clear the already raised message and populate your own message.
Kindly note here you can play around only with the message text. you cant influence the control flow.
BR, Saravanan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Himanshu,
As suggested by sarvanana remove the standard IWD Message and keeping the custom message :
public void wdDoBeforeAction(com.sap.tc.webdynpro.progmodel.api.IWDBeforeAction validation)
{
//@@begin wdDoBeforeAction
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
if(msgMgr.hasExceptions()){
msgMgr.removeMessage(msg);
//custom message
msgMgr.reportSuccess("Please enter a valid date in this format:"+"dd/MM/yyyy");
}
//@@end
}
//declare IWDMessage in begin others
//@@begin others
IWDMessage msg;
//@@end
Hope this helps.
Regards,
Saleem Mohammad.
Hi Himanshu,
As john said it is not possible to skip the standard validation thrown by webdynpro framework.
You can do a manual validation without binding the context value attribute to a dictionary type using SimpleDateFormat.
public boolean isValidDate(String date)
{
// set date format, this can be changed to whatever format
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date testDate = null;
// try to parse the string into date form
try
{
testDate = sdf.parse(date);
}
// if the format of the string provided doesn't match the format we
// declared in SimpleDateFormat() we will get an exception
catch (ParseException e)
{
errorMessage = "the date you provided is in an invalid date" +
" format.";
return false;
}
if (!sdf.format(testDate).equals(date))
{
errorMessage = "The date that you provided is invalid.";
return false;
}
return true;
} // end isValidDate
Hope this helps you.
Regards,
Saleem Mohammad.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i don't think it is possible
what you can do is disable the validation, you have to validate all the data manually by your own code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.