on 04-06-2007 11:33 AM
I want to generate server side alert, while editting the notification detail page. I need to write code into controller.
public Forward onSave(Forwards forwards) {
String title = getNotificationCustomController().getNotifDetailCallerTitle();
// Must be
// done
// first
Mam010 notif = (Mam010) getNotificationCustomController().getManipulateObject();
LongTextComponent ltComponent = (LongTextComponent) getComponent().getApplication().getComponent("longText");
LongTextCustomController ltcc = ltComponent.getLongTextCustomController();
if (notif == null) {
// notif object was not properly selected
return handleApplicationError(
forwards,
null,
"onSave",
PropertyMgr.getText("GENERIC_ERR_OBJECT_NOT_FOUND"));
}
// validate and set dates/times and other notif fields
if (!processNotification(notif, true)) {
return forwards.findForward("errorSave");
}
NotificationProcess nProcess =
(NotificationProcess) NamingService.getInstance().lookup(NotificationProcess.class.getName());
try {
//************************************************************************************************
// I am adding the code with reference to MAMCustomController.
String MAT=(String)getContext().getValue(MAMCustomController.NOTIF_MATERIAL_NUMBER);
if(MAT==""||MAT==null)
{
int k=3/0;
}
//********************************************************************************************
// get new long text
String longTextString = (String) getContext().getValue(NotificationUIHelper.NOTIF_LONG_TEXT);
if (longTextString != null)
ltcc.setManipulatedLongText(StringUtility.formatEndLine(longTextString));
getNotificationCustomController().evaluateValidationWarning();
nProcess.saveNotification(
notif,
longTextString,
getNotificationCustomController().getValidationWarning(),
MAMCustomController.VALID_LEVEL_DEFAULT);
}
catch(ArithmeticException ex){System.out.println("Functional Location is mandatory");}
catch(NullPointerException ex){System.out.println("Functional Location is mandatory");}
catch (ValidationException e) {
getContext().addValue(MAMCustomController.GENERIC_ERROR, PropertyMgr.getText(e.getMessage()));
if (e.getMessage().indexOf("_WAR_") >= 0) {
getContext().addValue("errorIsWarning", "true");
}
return forwards.findForward("errorSave");
} catch (ProcessException e) {
return handleRuntimeError(forwards, null, "onSave", PropertyMgr.getText(e.getMessage()), e);
}
// freesort - need to update as we added a new notif
if (ComponentStatus.getFreeSortIsActive()) {
FreeSortPersistanceMgr fspMgr =
(FreeSortPersistanceMgr) NamingService.getInstance().lookup(FreeSortPersistanceMgr.class.getName());
fspMgr.addKey(notif.getKey(), "NotifList");
}
Forward caller = getNotificationCustomController().getNotifCreateCaller();
if (caller != null) {
try {
updateAssociatedOrder(notif);
} catch (ValidationException e) {
getContext().addValue(MAMCustomController.GENERIC_ERROR, PropertyMgr.getText(e.getMessage()));
return forwards.findForward("errorSave");
} catch (ProcessException e) {
return handleRuntimeError(forwards, null, "onSave", PropertyMgr.getText(e.getMessage()), e);
} catch (BOException e) {
return handleRuntimeError(
forwards,
null,
"onSave",
PropertyMgr.getText("GENERIC_ERR_RUNTIME_ERROR"),
e);
}
}
try {
ltcc.resetCustomMethods();
getNotificationCustomController().setSelectedNotification(notif.getKey());
getNotificationCustomController().setNotifDetailCaller(caller, title);
getNotificationCustomController().setNotifCreateCaller(null);
return custom.checkMandatoryPartners(forwards, notif);
} catch (BOException e) {
return handleRuntimeError(forwards, null, "onSave", PropertyMgr.getText("GENERIC_ERR_RUNTIME_ERROR"), e);
} catch (ProcessException e) {
return handleRuntimeError(forwards, null, "onSave", PropertyMgr.getText("GENERIC_ERR_RUNTIME_ERROR"), e);
}
}
Could any body look at the code and tell me why this is not catching the error while I am trying to save null material no. The code is giving no error. Could anyone suggest me code.
Hi,
Thanks for your follow up. Yes firstly what I was doing is making changes into the existing controller then I thought I should create a new and there I can extend the previouds one and write new things. I tried so and i gave the new reference to the view file. but still it is not working.
Can I have a voice chat with you over this matter. If you dont mind......... It seems you have worked on the technology....
thanks
debarka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Debarka,
Please look at this <a href="/people/karsten.strothmann/blog/2006/12/12/the-mobile-client-application-framework--enhancing-mobile-applications-made-easy entry and make sure that it your code that is beeing executed. you should not use the precompile jsp version and you should use MAM sources to execute the application. Beware of the mam jar file in the lib folder as it get precedence on your code.
Bye!
Julien.
Hi Julien,
Actually I need to raise at alert while user is leavingg the material no field null.
That is the standard event handler for onSave(). I have starred the added code. rest I have just copied. Now the problem is any changes not getting reflected. I have simply added required code for that and prederminedly added code to raise a Arithmetic ecception but alas it does not getting reflected. I cant get why... Even I create a new controler extending this still it does not get reflected. I cannot understand the reason behind it. Should I do anything else to get my code reflected properly. If you go through the marked code you will see that if I leave a paricular field null while saving then it should raise an exception....
Debarka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Send the error, it will be much more useful. I don't think anybody will look at so much unexplained code.
Thank you,
Julien.
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.