on 06-25-2007 10:10 AM
Hi All,
I have one filed(say Name) and Save button in my iview. If Name has no value need to display mesg. In wdInit i have intialize the Name as (""), and i have declared simple type and done related code everything, so if Name has no value it is giving error when i click on Save...
If i provide value to Name and press Save, then error is coming,,,,,now my problem is if i remove entered text in Name and if i press Save it is not showing error mesg(becoz now it have null not ("") ). So to handle this i have done code, but it is not going to that Null condidtion.
IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();
Object attributeValue = wdContext.currentContextElement().getAttributeValue(fieldName);
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(fieldName);
if (attributeValue instanceof String) {
if (((String) attributeValue).length() == 0) {
String fieldLabel = wdContext.getNodeInfo().getAttribute(fieldName).getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,
IMessageMSAReclassApp.MESG,new Object[] { fieldLabel },true);
wdContext.currentContextElement().setSelTab(tabName);
}
else if (this.wdContext.currentContextElement().getAttributeValue(fieldName) == null ){
{ String fieldLabel = wdContext.getNodeInfo().getAttribute(fieldName).getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,
IMessageMSAReclassApp.MESG,new Object[] { fieldLabel },true);
Could anybody tell me how to compare null NWDS..i triend dirrecnt ways but it is not working for me...
Hi ,
Replace your code by the following :
if (this.wdContext.currentContextElement().getAttributeValue(fieldName) == null ){
{ String fieldLabel = wdContext.getNodeInfo().getAttribute(fieldName).getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,IMessageMSAReclassApp.MESG,new Object[] { fieldLabel },true);
}
elseif (attributeValue instanceof String) {
if (((String) attributeValue).length() == 0) {
String fieldLabel = wdContext.getNodeInfo().getAttribute(fieldName).getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,
IMessageMSAReclassApp.MESG,new Object[] { fieldLabel },true);
wdContext.currentContextElement().setSelTab(tabName);
}
why I am asking this of you because in the attribute value that you've entered is null then the first condition that you are checking itself will throw a null pointer exception.
So now onwards remember to check for the null before check for an empty string condition.
Regards
Amit
Message was edited by:
Amit Kesari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried all replies, still not working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can try this:
IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();
Object attributeValue = wdContext.currentContextElement().getAttributeValue(fieldName);
IWDAttributeInfo attributeInfo = this.wdContext.getNodeInfo().getAttribute(fieldName);
if (attributeValue instanceof String) {
if ((String)attributeValue == null ){
String fieldLabel = wdContext.getNodeInfo().getAttribute(fieldName).getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,
IMessageMSAReclassApp.MESG,new Object[] { fieldLabel },true);
}
}
Regards,
Satyajit.
hi ,
The only reason that the code wont go to the block could be that
"this.wdContext.currentContextElement().getAttributeValue(fieldName) == null "
condition is not getting satisfied can you check it.Because as per you have written
the String has been initialized by the framework at runtime once you are getting the an enabled input field in your case.Just change the first block if condition
from if (((String) attributeValue).length() == 0) to attributeValue.equals("");
and it will work.
Regards
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
null==this.wdContext.currentContextElement().getAttributeValue(fieldName)||){0==this.wdContext.currentContextElement().getAttributeValue(fieldName).lenght())
{
display error message
}
AM
Message was edited by:
Anoop Mathew
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi NR,
else if (this.wdContext.currentContextElement().getAttributeValue(fieldName) == null )
change to
<b>else if (null == this.wdContext.currentContextElement().getAttributeValue(fieldName) )</b>
Rgds
-SS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.