cancel
Showing results for 
Search instead for 
Did you mean: 

Simple alert message ques

Former Member
0 Kudos

Hi All,

I am running a webdynpro application. It has a textbox and on click of a button the control goes to the next page. I want to check if the text entered in the textbox has the characters "@" or "." present in it. If it is not present then i wish to give a alert message to the user and return the focus back on the text. Else the control goes to the next page.

Any inputs on this please.

Also how to add logging facilities in webdyn pro applications.

Points assured.

Regards

Nikhil Bansal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mikhil,

use indexOf to check if the text contains the char:

if (textVariable.indexOf('%')>0) .............

the method return - 1 if the character doesn't exist in the string. The same for "."

To show an alert message use this:

IWDMessageManager msg = wdThis.wdGetAPI().getComponent().getMessageManager();

msg.reportException("Error: " + textVariable + "not in string", false);

There are a lot of way to manage the error log but the above is the more simple.

Hope this help.

Vito

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi:

1. I assume that a "text box " is a textEdit

2. detect @ or . by indexOf if <0 , it is not in the string

3. conseqently if index of <0 , i do not go tothe next page

4, message can be done using message pool

String des= "blabla ";

Object[] arg = ;

MessageFormat message = new MessageFormat(wdComponentAPI.getTextAccessor().getText(IMessageItFinPlnComp.ADDITIONALINFO));

String text = (String)message.format(arg);

5.for logging you can have a simpel log like this:

public static void logString(String str) {

try {

FileWriter fw = new FileWriter("C:
temp
group.log", true);

String threadId = Thread.currentThread().getName();

fw.write("" + str + "\r\n");

fw.close();

} catch (IOException e) {

e.printStackTrace();

}

}

or more complicated using cache and making a commom DC

Regards