on 09-15-2005 6:58 AM
Hi
I have an application, in which 2 BigDecimal values are compared , and if they don't match, an error is to be displayed.
I am able to compare the values. But the message is not shown even when the condition is not met.
Code is as follows:
BigDecimal actualLiftingsTotal=wdContext.nodeContractVolumeResultViewNode().nodeOutput().nodeLi_Con_Nom().getLi_Con_NomElementAt(size-1).getAct_Lift();
BigDecimal contractVolumeTotal=wdContext.nodeContractVolumeResultViewNode().nodeOutput().nodeLi_Con_Nom().getLi_Con_NomElementAt(size-1).getCon_Vol();
BigDecimal Actual_Proposed_Total=actualLiftingsTotal.add(bdProp_Nom_Value);
try
{
if(Actual_Proposed_Total==contractVolumeTotal)
{
int flag2=1;
}
else
{
IWDMessageManager msgMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager();
IWDAttributeInfo attributeInfo=this.wdContext.getNodeInfo().getChild("ContractsVolumeResultViewNode").getChild("Output").getChild("Li_Con_Nom_output").getAttribute("Prop_Nom");
msgMgr.reportContextAttributeMessage(this.wdContext.currentContractVolumeResultViewNodeElement(),attributeInfo,IMessageContractVolumesComp.CHECK__PROPOSEDNOMINATION,new Object[] {Actual_Proposed_Total},true);
}
}catch(NullPointerException ex)
{
ex.printStackTrace();
}
This is being done on the Save Action Button.
Can anybody please help.
Thanks & regards,
Anupreet
Hi Anupreet,
Your code looks fine, don't know why you are not getting the message displayed. Anyway please try out this suggestion and see if it makes any differenece:
Please edit your message in the message pool such that it doesn't require any objects. (Use some plain error text initially). Then modify your else block like:
else
{
wdComponentAPI.getMessageManager().reportSuccess("Inside else block");
IWDAttributeInfo info = wdContext.getNodeInfo().getAttribute(IPrivate<your_View_name>.ILi_Con_Nom_outputElement.PROP_NOM);
IWDMessageManager messageMgr = this.wdComponentAPI.getMessageManager();
messageMgr.reportContextAttributeMessage(this.wdContext.currentLi_Con_Nom_outputElement(),info,IMessageContractVolumesComp.CHECK__PROPOSEDNOMINATION,null,true);
}
And inside your catch block do make sure to print the exception through wdComponentAPI.getMessageManager().reportWarning("ERROR"+e.toString());
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anupreet,
I suggest you to try to run a sample code by creating a new DC.
I think there is no need of try-catch block.
test this code..
public void onActionTest(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionTest(ServerEvent)
//String help = wdThis.wdGetContext().currentContextElement().getHelp();
//this.checkMandatory(help);
//wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();
BigDecimal no1 = wdContext.currentContextElement().getNo1();
wdComponentAPI.getMessageManager().reportSuccess("No-1 = "+no1);
BigDecimal no2 = wdContext.currentContextElement().getNo2();
wdComponentAPI.getMessageManager().reportSuccess("No-2 = "+no2);
BigDecimal no3 = no1.add(no2);
wdComponentAPI.getMessageManager().reportSuccess("No-3 = "+no3);
checkDecimal(no1,no2,no3);
//wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();
//@@end
}
public void checkDecimal( java.math.BigDecimal no3, java.math.BigDecimal no1, java.math.BigDecimal no2 )
{
//@@begin checkDecimal()
IWDMessageManager msgMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager();
IWDAttributeInfo attributeInfo=this.wdContext.getNodeInfo().getAttribute("No3");
if(no3.toBigInteger().equals(new BigDecimal(no1.add(no2).toBigInteger())))
{
wdComponentAPI.getMessageManager().reportSuccess("Successful No-3 = "+no3);
}
else
{
msgMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),attributeInfo,IMessageErrorTest.DECIMAL_TEST,new Object[] {"Not Equal"},true);
}
//@@end
}
Message key - DecimalTest
Messagetype :Error
messagetext : something...here..
try to execute this sample project successfully ...then you 'll come to know what mistake you have done.
I think spend some time in creating this sample pro. and test it.
Regards,
Karthick
Hi Karthick
The stacktrace is as follows:
java.lang.NullPointerException
at com.sap.bp.ngl.contvol.ContractVolumeResultView.onActionSave(ContractVolumeResultView.java:346)
at com.sap.bp.ngl.contvol.wdp.InternalContractVolumeResultView.wdInvokeEventHandler(InternalContractVolumeResultView.java:202)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:100)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:299)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:635)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:249)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:340)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:318)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:821)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:239)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
Thanks & regards,
Anupreet
Hi Anupreet,
Try this.
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getChild("ContractsVolumeResultViewNode").getChild("Output").getChild("Li_Con_Nom_output").getAttribute(IPrivateContractsVolumeResultView.ILi_Con_Nom_outputElement.PROP_NOM);
And make sure that your context name and PROP_NOM should be same.
Regards,
Karthick
Hi Anupreet,
Just trying to help you debug your application ...!
Before your comparison statement, just print the values of both the variables and make sure that they are populated properly
wdComponentAPI.getMessageManager().reportSuccess("Actual_Proposed_Total = "+Actual_Proposed_Total);
wdComponentAPI.getMessageManager().reportSuccess("contractVolumeTotal = "+contractVolumeTotal);
Then inside your if & else blocks try printing some text to make sure that the control reaches the desired block.
Hope this helps,
Best Regards,
Nibu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I have done exactly the way you mentioned karthick, and also tried the way bhavik had said.
Even during the debugging, i checked it, the right data is coming in the variables, it is being compared and on condition becoming false, control does reach the desired block. But the error message is not being displayed.
Can you please help in this, as i am clueless, where exactly the problem is arising.
Thanks & regards,
anupreet
Hi Anupreet,
Have you made the attributes which is representing the Bigdecimals as decimals?
1.means in the context select the attribute which is representing the big decimal and in the property -type make it as decimal.
now try.
2. And check whether yo have given message text or not,bcaz message text will be displayed in the browser instead of message key.check it out.
3.If you are getting any exception just lemme know.then easily we can debug it.
Regards,
Karthick
Hi Anupreet,
Write following line of code when both values are not same.
wdcomponentAPI.getMessegemanager().reportWarning("<Your messege>");
No need to write all other things.
Regards,
Bhavik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anupreet,
See this example code.
OnAction method.
public void onActionToResultView(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionToResultView(ServerEvent)
String name = wdThis.wdGetStartViewController().wdGetContext().currentContextElement().getC_name();
this.checkMandatory(name);
wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();
wdThis.wdFirePlugToResultView();
//@@end
}
Dont forget to follow these steps.
In the message pool
Write your message key like in my case -- MISSING_INPUT
Message Type - Error
Give some message text.
I think It should help you.
Regards,
Karthick
My Check Mandatory method
public void checkMandatory( java.lang.String name )
{
//@@begin checkMandatory()
IWDMessageManager messageManager = this.wdThis.wdGetAPI().getComponent().getMessageManager();
// Object attributeValue = this.wdContext.currentContextElement().getAttributeValue(name);
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute("name");
// if(attributeValue instanceof String){
if (name == null || name.equalsIgnoreCase("")){
messageManager.reportContextAttributeMessage
(this.wdContext.currentContextElement(),
attributeInfo,
IMessageStartView.MISSING_INPUT,
new Object[]{"name"},
true);
}//if
// }//if
//@@end
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anupreet,
On Action method
write your code like this as you said.
BigDecimal actualLiftingsTotal=wdContext.nodeContractVolumeResultViewNode().nodeOutput().nodeLi_Con_Nom().getLi_Con_NomElementAt(size-1).getAct_Lift();
BigDecimal contractVolumeTotal=wdContext.nodeContractVolumeResultViewNode().nodeOutput().nodeLi_Con_Nom().getLi_Con_NomElementAt(size-1).getCon_Vol();
BigDecimal Actual_Proposed_Total=actualLiftingsTotal.add(bdProp_Nom_Value);
then write one more method (like.. checkDecimals() )to test whether the decimal values are matching.
inside that method.
checkDecimals method write your code ..but to that check Decimals method you have to pass the parameters which do you want to match.
try
{
if(Actual_Proposed_Total==contractVolumeTotal)
{
int flag2=1;
}
else
{
IWDMessageManager msgMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager();
IWDAttributeInfo attributeInfo=this.wdContext.getNodeInfo().getChild("ContractsVolumeResultViewNode").getChild("Output").getChild("Li_Con_Nom_output").getAttribute("Prop_Nom");
msgMgr.reportContextAttributeMessage(this.wdContext.currentContractVolumeResultViewNodeElement(),attributeInfo,IMessageContractVolumesComp.CHECK__PROPOSEDNOMINATION,new Object[] {Actual_Proposed_Total},true);
}
}catch(NullPointerException ex)
{
ex.printStackTrace();
}
}
And in the message pool editor you have to create a new message for your error message.
If you are not understanding my idea.just lemme know I'll explain this with sample code.
Dont forget to reward the answers if you are satisfied.
Regards,
Karthick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.