on 08-30-2005 6:49 PM
Hi,
I have a node, called NODEA, under that i have 5 attributes, in my View Context which are mapped to Custom Controller. I created an action "SAVE" in View Controller. Now when i press SAVE button, i need to check all attributes whether it is empty or not. If they are empty i need to report an error to the user.
Could you please tell me how did you validated the model node attributes.
Thanks
Vijay
Hi Lakshmi, see my sample code...
// method for checking mandatory
public void CheckMandatory( java.lang.String EmpId, java.lang.String Emp_ID, java.lang.String displayValue )
{
//@@begin CheckMandatory()
IWDMessageManager msgMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager();
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(Emp_ID);
if(EmpId==null || EmpId.equalsIgnoreCase(""))
{
msgMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),attributeInfo,IMessageLoginComponent.MISSINGI_NPUT,new Object[] {displayValue},true);
}
else
{
try
{
int age = Integer.parseInt(EmpId);
if(Emp_ID.equalsIgnoreCase("Age"))
{
if(age > 100)
{
msgMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),attributeInfo,IMessageLoginComponent.AGE_GT100,new Object[] {displayValue},true);
}
}
}
catch(NumberFormatException NFE)
{
msgMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),attributeInfo,IMessageLoginComponent.DATE_IS_IN_PAST,new Object[] {displayValue},true);
}
}
//@@end
}
//Method for checking not null
public void CheckSexNotNull( com.sap.emp.info.Sex value, java.lang.String label )
{
//@@begin CheckSexNotNull()
IWDMessageManager msgMgr = this.wdThis.wdGetAPI().getComponent().getMessageManager();
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(label);
if(value==null)
{
msgMgr.reportContextAttributeMessage(this.wdContext.currentContextElement(),attributeInfo,IMessageLoginComponent.EMPID__MISSING,new Object[] {label},true);
}
//@@end
}
//On Action call these methods.
CheckMandatory(empId,"EmpId","Employee ID");
CheckSexNotNull(sex,"Sex");
wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();
wdThis.wdFirePlugGoToEmpDetails(UserName ,Sex);
Is it helping you?
Just inform me if u need more .....code snippet?
Regards,
Karthick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
use webdynpro s default functionality, keep the fields mandatory and use the message manager class to report your exceptions, based on the values present when the user presses save.
u need to check for null as nibu says some times u may also have to take care of "" as well.
regards
vln
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lakshmi,
If you are creating only one element for the node and if you are not initializing your attributes anywhere, these two lines of code should serve your purpose.
Iprivate<View_name>.INODEAElement elmt = wdContext.currentINODEAElement();
if(elmt.get<Attrubte_name>()==null)
wdComponentAPI.getMessageManager.reportWarning("your msg);
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,
Do check the following link for Validating actions.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/us... validating and non-validating actions.pdf
Regards,
Vijith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lakshmi ,
You can check the size of the node by using
wdcontext.node<node name>.size()
IF it is zero give the warning message
Hope this helps you
Regards
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I dont know whether i got your requirement right.
Suppose that you have bound your input field to the attributes in node a then you can get the values in a particular input field as
wdContext.current<Name of Node>Element().get<Name of atrribute>();
You can check whether this value is empty or not and print out the error message using message manager like
wdComponentAPI.getMessageManager().reportException("No Value",true);
Hope this helps.
Revert back for further clarification.
Regards,
Vijith
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 | |
23 | |
11 | |
9 | |
8 | |
5 | |
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.