cancel
Showing results for 
Search instead for 
Did you mean: 

Limit field length and display remaining characters?

Former Member
0 Kudos

Hi Experts

I have a requirement to limit the number of characters being entered in a textedit, and also to display the number of characters remaining as the employee types.

I know that I can limit the number of characters customizing the data type linked to the field, but how do I show the remaining characters?

There are no Events linked to the textedit filed that I can make use of.

Thanks in advance.

Anton Kruse

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi

How the data will be there in Textedit

1. Is user will enter the data or

2.This field will prefilled through context attribute.

Second one right?

String text = wdcontext.currentcontextelement.getText(); //It has the whole current value

//Example
public class SubstringExample1{
    public static void main(String[] args){
        String string = "Rajesh kumar"; 
        System.out.println("String : " + string);
        String substring = string.substring(3);
        System.out.println("String after 3rd index:
 " + substring);   
        substring = string.substring(1, 2);
        System.out.println("Substring (1,2): " + 
substring);
    }
}

BR

Satish Kumar

Former Member
0 Kudos

Hi Satish

No, 1st one, the user will enter the data.

And for each keystroke the "Remaining Total" should decrease by 1.

is this possible?

Former Member
0 Kudos

Anton,

I don't think there's an active listnener for WD-Java UIs so you can manipulate the text being entered on the UI element. What you can only do is post-action checks or validations. Just like what the rest are telling you... or just prompt the user that they have entered an invalid number of characters for the following field.

Regards,

Jan

Former Member
0 Kudos

Ok, thanks anyway.

Answers (1)

Answers (1)

former_member185086
Active Contributor
0 Kudos

Hi

If data source is context then you can parse it through JAVA STRING utility like take the complete string in one temporary variable then print the remaning characters Since all the time Input length will constants so just write one method with these parameter and use it everywhere.

Hope I am clear?

Best Regards

Satish Kumar

Former Member
0 Kudos

Clearish...

Data source is context.

I'll give it a shot.

Will this value change as the person is typing?

Do you have a code sample?

Thanks

Anton

chintan_virani
Active Contributor
0 Kudos

Well the type of functionality you want is Client side scripting which is not supported in Web Dynpro. You cannot have mousedown, keypressed eventing in Web Dynpro as Web Dynpro supports only server side scripting. So most likely after the user has typed the details you may trigger a validation using the supported events and check the no. of characters he/she has entered.

Chintan