Skip to Content
0
Former Member
Jan 02, 2008 at 05:32 AM

hw to block the 2nd view if a mandatory field is null in dynamic generation

15 Views

hi,

i hv created the following application:

http://ep62:50100/webdynpro/dispatcher/local/TutWD_Dynamic/DynamicApp?SAPtestId=103

i hv made the firstname as mandatory.

bt when i click on the save btn it goes to the nxt view.

hw do i stop it?

i hv written the following code in my save btn:

public void onActionGenericAction(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String Command )

{

SomeBackEnd theBackend = new SomeBackEnd();

SomeBackEnd.FieldDescriptor fld=null;

IWDNode node = wdContext.currentContextElement().node ().getChildNode("DynamicNode", 0);

IWDNodeElement nodeElement = node.getCurrentElement();

if(SomeBackEnd.FieldDescriptor.class.getName()=="firstName")

{

wdComponentAPI.getMessageManager().reportSuccess("PLEASE ENTER YOUR FIRST NAME");

}

else if (Command.equals("save"))

{

String result = "Your data was successfully saved:" + "\n\r";

/*Object obj;

//obj = nodeElement.getAttributeValue("HomePage");

obj=wdContext.getNodeInfo().getAttribute("HomePage");

if(obj==null)

obj="<NULL>";

result = "Your data was successfully saved:" + "\n\r";

result = result + "HOME PAGE" + " :" +obj.toString() + "\n";*/

for (int index = 0; index < theBackend.getNumberFields(); index++)

{

fld = theBackend.getField(index);

Object value = nodeElement.getAttributeValue(fld.getName());

if (value == null)

{

if(fld.getName()=="firstName")

{

wdComponentAPI.getMessageManager().reportSuccess("Please Enter Your First Name ");

wdContext.currentContextElement().setVisible(WDVisibility.NONE);

}

break;

}

result = result + fld.getName() + " : " + value.toString() + "\n";

}

wdContext.currentContextElement().setVisible(WDVisibility.VISIBLE);

wdContext.currentContextElement().setResult(result);

}

else if(Command.equals("delete"))

{

for (int index = 0; index < theBackend.getNumberFields(); index++)

{

fld = theBackend.getField(index);

nodeElement.setAttributeValue(fld.getName(), fld.getInit());

}

wdContext.currentContextElement().setVisible(WDVisibility.NONE);

}

plz help.

regards,

ankita