cancel
Showing results for 
Search instead for 
Did you mean: 

Form Valadation

Former Member
0 Kudos

Hi

My application is a 4 step process. From Step1 before moving onto Step 2 there is some valadation, presently only on a single field "Reason". The requirment is that once an error is encountered processing stops and the message displayed.

cheeckMandatory("Reason");

wdComponentAPI.getMessageManager().raisePendingException();

wdThis.wdFirePlugNextOut(); //go to next step

Where "cheeckMandatory" is as:

public void cheeckMandatory( java.lang.String fieldName )

{

//@@begin cheeckMandatory()

IWDMessageManager messageMgr = this.wdComponentAPI.getMessageManager();

Object attributeValue = this.wdContext.currentContextElement().getAttributeValue(fieldName);

IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(fieldName);

String description = attributeInfo.getSimpleType().getDescription();

Object o = this.wdContext.currentContextElement();

}

If the line

wdComponentAPI.getMessageManager().raisePendingException();

is included and in the event the Reason field is left blank then we get the following exception:

Error stacktrace:

com.sap.tc.webdynpro.progmodel.controller.MessageManager$AbortMessageManagerException:

at com.sap.tc.webdynpro.progmodel.controller.MessageManager.raisePendingException(MessageManager.java:404)

at com.sap.te.CreateClaimStep1.onPlugNextIn(CreateClaimStep1.java:214)

at com.sap.te.wdp.InternalCreateClaimStep1.wdInvokeEventHandler(InternalCreateClaimStep1.java:149)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.navigate(ClientApplication.java:768)

at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:350)

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)

If I remove the line "wdComponentAPI.getMessageManager().raisePendingException();" The error is displayed on the screen correctly but we move to the next step. Can anyone tell me what might be causing the exception above as the line "wdComponentAPI.getMessageManager().raisePendingException();" stops any further processing.

Thanks

Damien

Accepted Solutions (1)

Accepted Solutions (1)

former_member189631
Active Contributor
0 Kudos

Hi Bo,

Please follow these steps to set a field as Mandatory,

*Create a Lable and Input Field.

*Go to Input fields State property and select "Required"

*In Label Go to the Label For Property and select the Name of your Input Field.

Regards,

Ram.

Former Member
0 Kudos

hi Ramganesan

This I had done ... but what you suggest is only for display purposes as far as I understand ..... the code above is the logic that supports this ....

Cheers

Damien

abhijeet_mukkawar
Active Contributor
0 Kudos

hi

could you solve your problem?

regards

Former Member
0 Kudos

Hi Bo,

In your check mandatory

public void cheeckMandatory( java.lang.String fieldName )

{

//@@begin cheeckMandatory()

IWDMessageManager messageMgr = this.wdComponentAPI.getMessageManager();

Object attributeValue = this.wdContext.currentContextElement().getAttributeValue(fieldName);

IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(fieldName);

String description = attributeInfo.getSimpleType().getDescription();

Object o = this.wdContext.currentContextElement()

<b>if(description==null)

{

messageMgr.reportExecption("<error message>",true);

// the boolean value will cancels the navigation

}</b>

}

// remove the line wdComponentAPI.geMessageManager.raisePendingException();

hope this solves your problem

Answers (2)

Answers (2)

Former Member
0 Kudos

hi.,

chk this link out

Former Member
0 Kudos

Hi

prasy p - From the link you sent, unless I am mistaken this is what I am doing.

Abhijeet - Thanks for that . I imagine that the code you gave me will work. But from my understanding of the tutorials etc:

if (attributeValue instanceof String) {

if (((String) attributeValue).length() == 0) {

String fieldLabel = this.wdContext.getNodeInfo().getAttribute(fieldName).getSimpleType().getFieldLabel();

messageMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),

attributeInfo,IMessageTE.MISSING_INPUT,

new Object[] { fieldLabel },

true);

Should add the message to the message manager (but not display). So from the following three steps which are executed when the "Next" button is clicked:

cheeckMandatory("Reason");

wdComponentAPI.getMessageManager().raisePendingException();

wdThis.wdFirePlugNextOut();

Step 1 - cheeckMandatory("Reason") - Checks if the field is populated, if not a message is added to the message mannager.

Step 2 - wdComponentAPI.getMessageManager().raisePendingException();

Will raise and display the messages. The important point here is the Step 3 is NOT exectued i.e it will not return.

Step 3 - Go to the next screen.

Am I correct in my analysis.

Thanks

Damien

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

dont use raisependingexception () , we dont need that now,your code will be like,

you must have some value attribute bound to your input fields, lets say it is ctx_reason , so code will be,

IWDMessageManager msgmnr = wdComponentAPI.getMessageManager();;

IWDAttributeInfo attrreason = wdContext.getNodeInfo().getAttribute("ctx_reason");

if(wdcontext.currentcontextelement.getCtx_reason() == null)

{

msgmnr.reportContextAttributeMessage(wdContext.currentContextElement(),attrreason,

IMessageConMes.NO_REASON,new Object[]{},true);

}

else

{

wdThis.wdFirePlugNextOut();

}

//just need to define the error message in message pool named NO_REASON

//dont gvie call to any function directly write this code on button click

i hope this will solve your issue

regards

abhijeet_mukkawar
Active Contributor
0 Kudos

hi,

this is because you are using,

wdComponentAPI.getMessageManager().raisePendingException();

according to your functionality, it should proceed only if some condition is met, so use something like following code,

i.e, use reportContextAttributeMessage() of message manager instead of raisePendingException(), like

IWDMessageManager msgmnr = wdComponentAPI.getMessageManager();;

IWDAttributeInfo attrYear = wdContext.getNodeInfo().getAttribute("year");

if(wdContext.currentContextElement().getYear() == 0)

msgmnr.reportContextAttributeMessage(wdContext.currentContextElement(),attrYear,

IMessageConMes.AGE__LIMIT,new Object[]{},true);

//here AGE_LIMIT is the error message defiend in the message pool

also refer this document for the same

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f4d79e59-0601-0010-0689-89670315...

regards