cancel
Showing results for 
Search instead for 
Did you mean: 

Adding validations to ESS iViews

Former Member
0 Kudos

Hi guys,

I'm trying to add a check in 1 of ESS iViews e.g. Personal Data. The Check is that when the Review button is clicked, it would validate a field on the Personal Data iView. Thus, I need to add this piece of code somewhere, can someone advise me where I can add it in? Is it in ess/per/VcPersInfoDetailNav? Or somewhere else?

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Guys, for those who were able to insert the code in the OnAction method, were your context nodes and values populated? Because by default, it seemed to me it is empty at VcPersInfoDetailNavi.. Could you please share how did you pass it in?

Former Member
0 Kudos

Hi Mandeep,

I've tried that method already but it seems that there is a problem doing so. Basically, there are 2 DCs:

- ess/pdata, where web dynpro component Personal Data iView (VcPerPersonalDetail) resides

- ess/per, where web dynpro component VcPersInfoDetailNav resides (contains the OnAction button)

Since the buttons and actions lie in VcPersInfoDetailNav, so the validation is recommended to be in the OnAction method in VcPersInfoDetailNav. However, as I explained earlier, VcPersInfoDetailNav does not have any Context nodes and values passed to it (surprisingly).

Thus, as you adviced, I need to create a validation method in VcPerPersonalDetail that would be called by VcPersInfoDetailNav.OnAction when the button is triggered. To do so, I would need to create a dependency btw ess/pdata and ess/per. However, a dependency already exists btw them (ess/per is a used DC of ess/pdata). And by making ess/pdata a used DC of ess/per for the method to be called, this would create a cyclic dependency whereby both DCs are used DCs of each other and from what I read, it seems this is disallowed.

A possible solution to it would be to create a new DC to insert this validation and VcPerPersonalDetail would have to map its context nodes & values to it, and VcPersInfoDetailNav.OnAction would call that method. But this would be my last resort due to the effort required.

I'm running out of ideas as to how to do these validations. I can't believe SAP would make it so hard for us to modify the codes to insert validations?

Former Member
0 Kudos

Hi

As per details provide by u about your Dc's,

Dc ESS-PDATA ie VCPerPersonnelDetails is Data provider for other components which contains Context and other logic.

DC ESS-PER ie VCPersInfoDetailNav which must be consumer DC containing buttons

So you can create public part in DC ESS-PDATA and use it in DC ESS-PER.

(what you are doing is opposite of this.Your data provider is using DC which have noting to share)

After using Dc in ESS-PER you can embed the view of ESS-PDATA in ESS-PER using ViewContainerUIElement.

Here on action of button you can call method of DC ESS-PDATA for validations.

Use DC ESS-PDATA in Properties of view controller under required components and to call method at OnAction() of button in ESS-PER put this code

wdThis.wdGet<ComponentName>InterfaceController().<Method>() ;

NOTE: Your methods will be in DC ESS-PDATA which is data provider and have context.

Mandeep Virk

Former Member
0 Kudos

Hi Mandeep,

This i realise, is also not possible as by adding ess/pdata as a used DC to ess/per, this would create a cyclic dependancy as ess/per is already a used DC of ess/pdata and this is not allowed. Thus this rules this method out.

Former Member
0 Kudos

Remove Ess/Per from the used Dc's of Ess/Pdata build it and do it as mentioned above.

It is recommended and is very much possible.

There is no significance of using a Caller Dc in Source dc and access Source Dc's Data.

Go ahead and let me know if u face any complexities.

Mandeep Virk

Former Member
0 Kudos

I don't think I can insert that code in the component VcPersInfoDetailNavi as the code needs to call the context and get the attribute information and values. However, VcPersInfoDetailNavi does not have the context information passed to it. How did u guys obtain the context info it?

Edited by: zhenmin wang on Jul 7, 2008 8:59 AM

Former Member
0 Kudos

So Create a method in the same controller where your Context resides and call that method in your view controller VcPersInfoDetailNavi.

To call this method use your controller containing Context in Properties of View VcPersInfoDetailNavi as Required Controllers.

Under OnAction() in view controller put this code

wdThis.wdget<your Required Controller>.yourMethod() ;

This will call method on click of button where you are validating.

Mandeep Virk

Former Member
0 Kudos

Hi Mandeep,

THe DetailNaviView view-controller does not have IWDMessageManager class, IWDAttribute class and the Context does not contain the nodes. Thus, when I try to implement the code, it is unable to resolve those types. Is this the correct component to insert this code?

Former Member
0 Kudos

These two are pre defined APIs so you must have it in your NWDS just check it once.otherwise type it and then do organise imports

Former Member
0 Kudos

Hi

Paste this code in your OnAction() of view controller where you want to do validation.

Press CNTRL +SHIFT +O this will organize imports as these are default API's.

Mandeep Virk

Former Member
0 Kudos

just try that above code in Action of particular Review button it willl work .

Former Member
0 Kudos

Say I've added in a new custom field called Date of Religion and I want to compare it with Date of Birth. When the Review button is clicked, the validation needs to check that If user's input of Date of Religion is before Date of Birth, Display error message and stop navigation.

Former Member
0 Kudos

hi

Create two value attributes DateOf Birth and DateOfReligion of type date in a node.


Date date = new Date(System.currentTimeMillis());
wdContext.current<value node>Element().setDateOfBirth(date);           // Say date of birth is current date;

if ( wdContext.current<value Node>Element().getDateOfReligion().before(date) ){

    IWDAttributeInfo atribInfo = wdContext.node<value node>().getNodeInfo().getAttribute("DateOfReligion");
    IWDMessageManager msgmgr = null;
    IWDNodeElement element = wdContext.current<value Node>Element();
    msgmgr.reportInvalidContextAttributeException(element,atribInfo,"Invalid Date of Religion",true);

}

Mandeep Virk

nikhil_bose
Active Contributor
0 Kudos

try this code in onAction() of Review / Navigation button

java.sql.Date birthdate = null;

java.sql.Date religiondate = null;

try{

birthdate = wdContext.current<Node>Element().getDateOfBirth();

religiondate = wdContext.current<Node>Element().getDateOfReligion();

if( religiondate.before(birthdate)) {

wdComponentAPI.getMessageManager().d.raiseException("Invalid Date ranger", true);

}else {

// navigate

}

}catch(NullPointerException e) {

wdComponentAPI.getMessageManager().d.raiseException("Please enter Date", true);

}

nikhil

Former Member
0 Kudos

Hi Tulasi,

Do you have any sample code as to how to check a field of a particular infotype?

Former Member
0 Kudos

can u tell me the exact reuirement i.e., which type of field do you want to validate ? please mention clearly

Former Member
0 Kudos

HI

Try to wirte the code in Review button action and do validation on that particular method.

Thanks,

Tulasi