on 08-09-2006 2:58 AM
Hi,
1)I have a text field.In that text field i can only enters numbers.If suppose someone enters something other than numbers,then it should display a message that "Enter Valid number".How can i do this?
2)I have an application.Suppose i want to create a new user,then it should display a auto generated number in UserID field.How can i do this?
Thanx & Regards
Anirudh
Message was edited by: Armin Reichert
(deleted exclamation marks)
For query 1) you can do this:
try
{
int i = Integer.parseInt(wdContext.currentContextElement.myfield);
}
catch (NumberFormatException e)
{
wdComponentAPI.getMessageManager.reportContextAttributeMessage(nodelement,attribute,messageItem, object[]{},false);
}
For query 2, auto-generation usually has persistency involved. Is this persistency in R/3 ? If yes and maintained as a number range in SNRO transaction, you can use NUMBER_GET_NEXT function module to retrieve the next number.
Regards,
Subramanian V.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
here r the solutions for your Queries plz try.
try
{
int i = Integer.parseInt(wdContext.currentContextElement.myfield);
}
catch (NumberFormatException e)
{
wdComponentAPI.getMessageManager.reportContextAttributeMessage(nodelement,attribute,messageItem, object[]{},false);
}
Plz set the identity column property to 'yes' in the design of that DB table using Enterprise manager.
or
in query analyzer you can include the following line while creating table.
<column name> <datatype> identity(<start from>,<increment>)
strat from -> starting number like 1 or 10 etc..
increment -> increment value like 1 or 2..
this will generate an auto numbers in that column and we need not to insert.
FYI : kindly dont forget to reward points.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for Query 1, you can bind the integer datatype attribute to the text field. then if you enter other than numbers, it will handle the validation and raise the exception with a messsage.
for Query 2,
type 1: you can set the identity column property to 'yes' in the design of that DB table using Enterprise manager.
type 2: in query analyzer you can include the following line while creating table.
<column name> <datatype> identity(<start from>,<increment>)
strat from -> starting number like 1001 or 100001 etc..
increment -> increment value like 1 or 2..
it will generate auto numbers in that column.we need not to insert.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
1.Parse the context attribute of type string,as
try
{
Integer.parseInt(wdContext.currentContextElement.get<Attribute>);
}
catch(Exception e)
{
wdComponent.getMessageManager().reportWarning("Your message of validation");
}
}
2.If u use database means , find the maximum and add to that and display
Regards,
Saravanan K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One correction: It does not raise an exception but displays an error message on that context
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For query 1: If you are not really particular about what error message should be displayed, then you can bind the input field to a context attribute of type 'integer'. Web Dynpro will do the validation and raise a context validation exception for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Other way to validate field. keep all validation for number, Id and alphanumeric in java class inside webdynpro project.
Use that java class for validation
Validation.java:
public boolean numberValidation(String number) {
final char[] numbers = number.toCharArray();
int count=numbers.length;
for (int length = 0; length <count; length++) {
letter = numbers[length];
if ((letter >= '0') && (letter <= '9')) continue;
return false; // invalid
}
return true; // valid
}
In webdynpro
if (EmpID ==null || EmpID.trim().length()==0 ){
manager.reportContextAttributeMessage(
context,attributeInfo,
IMessageEmpComponent.EmpID_NULL,new Object[]{""},true);
}else if(!validation.numberValidation(EmpID)){
manager.reportContextAttributeMessage(
context,attributeInfo,
IMessageEmpComponent.EMP__INVALID,new Object[]{""},true);
}
manager.raisePendingException();
Second Question: waiting for experts reply.
Regards
Suresh KB
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.