on 11-17-2006 7:00 AM
Hi Gurus,
I am beginner in webdynpro trying to implement IWDMessageManager but no success.
I have a created a Name text filed on iView and I would like to display error message bottom of this filed as warning message "Please enter the text for the name filed"
I have created a Node as KrishData , Element is : Name
Iwritten this code but it not working for me.
IWDMessageManager msg = wdComponentAPI.getMessageManager();
validateInput()
{
if(wdContext.nodeKrishData().currentKrishDataElement().getName()== null) {
msg..reportMessage("Please enter the text for the name filed");
}
any help will be rewarded, many thanks
Krishi
Hi,
Write the following code
IWDMessageManager msg = wdComponentAPI.getMessageManager();
validateInput()
{
if(wdContext.nodeKrishData().currentKrishDataElement().getName()== null) {
msgMgr.reportMessage(IMessageComp.ERROR, null, true);
//Here IMessageComp is your MessagePool interface. you can write IMessage and your componet name.
}
before writing the code you will have to add a message key in MessagePoll entry in your component.In the code ERROR is the message key. And select the mesage type as error and write your message "Please enter the text for the name filed" in the message text.
Regards
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai Krish,
U can Try This :
validateInput()
{
if(wdContext.nodeKrishData().currentKrishDataElement().getName()== null) {
<b>wdComponentAPI.getMessageManager().reportWarning(("Please enter the text for the name filed");</b>
}
Regards,
Ramganesh,
Caritor India Pvt Ltd.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Many thanks for your qquick response Lohi,
see here my code
public void wdDoInit()
{
//@@begin wdDoInit()
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
if(wdContext.currentStudentElement()== null)
msgMgr.reportmessage("Please eneter Name/Name should not be blank");
//@@end
}
The method reportMessage string is undefined for the type IWDMessageManager when i place mouse on reportMessage becausee there showing as an error.
Many thanks lohi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
public void wdDoInit()
{
//@@begin wdDoInit()
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
if(wdContext.currentStudentElement()== null)
msgMgr.reportmessage("Please eneter Name/Name should not be blank");
//@@end
}
// here u can get the value from the attribute
like
try this code.
String ram="";
if(ram!=null)
ram= wdContext.currentStudentElement().get<AttributeName>();
else
msgMgr.reportException("Error",true);
Thanks,
Lohi.
Hi Friends Many thanks for your replies , i applied the code snippet which you send to me but it is showing the following error message.....
The method reportmessage string is undefined for the type IWDMessageManager
here i tried to use the reportMessage(IWDMessage, Object[],boolean);
but this is also not working, i am not sure where i am doing mistake
Krish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krish,
As per the code u posted, u r using "msg.reportMessage(IWDMessage, Object[], boolean)" method. For this method u have to pass IWDMessage not a string as u code earlier "msg.reportMessage("Please enter the name field");
U can IWDMessage message in the message pool. In ur component hierarchy u will have MessagePool right click on that and "Open Message Editor" there u can create a message using "Add message" icon. it will ask for message key, message type and text.
Pass the message key in report message method
eg: msg.reportMessage(I<Ur component name>Comp.<MESSAGEKEY>, null, true);
Instead of this i think u can use reportWarning method which will take string as an argument.
eg: msg.reportWarning("Please enter name field");
i think ur if condition is ok u can check with length() ur getName() field.
Try this
Regards,
Aparna. P
Hi,
try like this.
try{
String rama = wdContext.currentKrishDataElement().getName()
}
catch(Exception e)
{
wdComponentAPI.getMessageManager.reportException("Please Enter input Value",true);
}
This make sense.
Other wise
String rama="";
if(rama!=null)
rama = wdComponent.currentKridhnaNodeElement().getName();
else
wdComponentAPI.getMessageManager.reportException("Please Enter input Value",true);
This might helps you.
Thanks,
Lohi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krish,
As per my understanding you are not able to see any message even though you didnt enter any message in the input field. Correct me if my understanding is wrong..
If your problem is not seeing any message the following is the solution:
Change your if condtion to the following...
<b>String name = wdContext.nodeKrishData().currentKrishDataElement().getName();
if(name == null || name.trim().length()>0) {
msg..reportMessage("Please enter the text for the name filed");
}</b>
Regards
Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Check The cardinality of the node is 1..1
Kind Regards
Mukesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In this case do following
In Init() method
I<<ViewName>>.IKrishDataElement ele=wdContext.createKrishDataElement();
ele.setName("xxxxx");
wdContext.nodeKrishNode().addElement(ele);
While checking you need to
if(wdContext.currentKrishDataElement().trim.equals("")
man.reportmessage("Please eneter Name/Name should not be blank");
2nd Solution
if(wdContext.currentKrishDataElement()==null)
man.reportmessage("Please eneter Name/Name should not be blank");
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishi,
Are you getting NullPointer exception ??
If so pleas emake sure that you are populating the context in init() method.
otherwise the staement "wdContext.nodeKrishData().currentKrishDataElement()." will raise nullpointer exception.
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
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.