Does it has some method to set Max Length on Field!

I want to set a maximun length on textfield and jtable cell to control the number of character on the field.
do you have any way?
thanks!

aaaaalmost, quizmaster.
But your code doesnt check the result size.
If offs = 100 and maxlength = 100, it would
allow any String to be inserted.
Anyway...is a detail of course.
one other possibility, also improveable:
public class CharacterLimitedDocument extends PlainDocument
  private int maxNumberOfCharacters = 64;
  public CharacterLimitedDocument(int maxCharacters )
    super();
    this.maxNumberOfCharacters = maxCharacters;
  public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
    if( this.getLength() + str.length()  < maxNumberOfCharacters )
       super.insertString(offs,str,a);
} // CharacterLimitedDocument

Similar Messages

  • How to set max length for TextField ?

    how do i go about setting a max length for a TextField in jdk1.1.8 ?
    a while back there was a topic on this but it was for jdk1.0
    please help

    well if it works in 1.0 it will most likely also work in 1.1.8 if it is depricated you can use the -deprication option during compilation to see what is derpricated and what method i advised to use now.
    there may however be an easyer way in 1.1.8 but i don't know that.
    hope this helps you,
    Robert

  • Setting max length of the field when using Context Model Node

    I have created a model using Import Adaptive Web Service model option (a web service was a wrapper around SAP BAPI function module).
    There were no dictionary types created in the Local dictionary as a result of import.
    I have mapped the context of the controller to the model node.
    One of the fields in the model is name     CUSTOMER_NUMBER type string;
    Corresponding element in the wsdl of the web service is
    <xsd:element name="CUSTOMER_NUMBER" type="tns:char10" />
    I have created a view with the input filed mapped to the CUSTOMER_NUMBER field of the model node.
    When I type more than 10 chars into the field and hit the search button, I get a com.sap.dictionary.runtime.Ddcheck exception that the length of the field should be less than 10 chars.
    How can I set the max length of the field in design time to prevent runtime exception?
    Thanks,
    Julia

    Thank you for your reply.
    Java trim function will trim the white spaces only, not the characters.
    I can code check length functionality before calling execute function (the function that call the web service).
    I can also create a dictionary structure based on the model structure; create a context value node based on the dictionary structure and use WDCopyService API to move the data between value node and model node.
    I was looking for the best practice...
    When importing model based on Adaptive RFC, the dictionary structures are imported together with the model. This does not happen for Adaptive web service - hence there is a need to add coding for simple checks.
    Julia

  • Set max length for input parameter in SSRS

    I have an input parameter (@year)   to display a simple report. This input parameter taken Year from user (ex: 2015) manually. Here my problem is to restrict the user to max length of
    4. It should allow only (ex:2015) not (ex:20155) like that. Can any one please suggest me how to do this. 

    Hi SaikumarN,
    According to your description, you want to restrict the length of values which user type in the parameter box.
    In Reporting Services, it’s not supported to limit the length of the typed value in the parameter box currently. For your requirement, you could provide Microsoft a feature request at
    https://connect.microsoft.com/SQLServer, so that we can try to modify and expand the product features based on your needs.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • Set internal length for field without reference in FM REUSE_ALV_GRID_DISPLA

    Hi Abapers,
    Currently I use FM REUSE_ALV_GRID_DISPLAYfor my report. The problem is, my internal table contain some field which have no reference to any data dictionary.
    This part of my code when set that kind of field:
       z_field_cat-ref_tabname = ''.
       z_field_cat-ref_fieldname = ''.
    z_field_cat-tabname = 'T_OUT_FINAL'.
        z_field_cat-fieldname = 'ARKTX'.
        z_field_cat-col_pos = z_colpos.
        z_field_cat-hotspot = 'X'.
        z_field_cat-outputlen = '200'.
        z_field_cat-seltext_m = 'Comments'.
        z_field_cat-ddictxt = 'M'.
    *{   INSERT         SRPK900238                                        1
        z_field_cat- = 'char'.
        z_field_cat-ddic_outputlen = '5'.
        z_field_cat-intlen = '5'.

    Sorry, I'm just not finish typing when accidently push "Post Message".
    This the full question of mine.
    Currently I use FM REUSE_ALV_GRID_DISPLAYfor my report. The problem is, my internal table contain some field which have no reference to any data dictionary.
    This part of my code when set that kind of field T_OUT-ARKTX into t_field_cat.
        z_field_cat-ref_tabname = ' '.
        z_field_cat-ref_fieldname = ' '.
        z_field_cat-tabname = 'T_OUT'.
        z_field_cat-fieldname = 'ARKTX'.
        z_field_cat-col_pos = 5.
        z_field_cat-hotspot = 'X'.
        z_field_cat-outputlen = '200'.
        z_field_cat-seltext_m = 'Comments'.
        z_field_cat-ddictxt = 'M'.
        APPEND z_field_cat TO t_field_cat.
    t_field_cat will be exported in FM 'REUSE_ALV_GRID_DISPLAY'
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program                           = z_repid
            i_callback_html_top_of_page             = 'ALV_TOP_PAGE'
            it_fieldcat                                         = t_field_cat
            i_save                                              = 'A'
          TABLES
            t_outtab                                           = t_out_final
          EXCEPTIONS
            program_error                                   = 1
    In internal table T_OUT, ARKTX length = 200. But somehow when it is displayed in ALV, it just show 128 characters.
    I have tried some parameter in t_field_cat to set length to be 200. I used intlen. But it doesn't work.
    Do any of you have any idea to solve this problem?
    Thank you
    Regards
    Hadi

  • Does anyone has a method of  getting a certain file?

    Can anyone help me? I need a method in getting a certain file. Thank you in advance.

    Ok, for exmple you could do something like this :
    read the file line by line
    add each line to an ArrayList
    for each line increment a counter
    return the counter
    ArrayList lines = new ArrayList();
      public static int process(String pathToFile) {
        File file = new File(pathToFile);
        int counter = -1;
        if (file.isFile()) {
          counter++;
          try {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            String line;
            while ( (line = reader.readLine()) != null) {
              lines.add(line);
              counter++;
            reader.close();
          catch (IOException ioe) {
            ioe.printStackTrace();
        return counter;
    }

  • Why does Firefox disable some Japanese character sets?

    Firefox 3.5.5 on Mac. Started yesterday at a point. My Japanese character selection (Kotoeri) disables all but Romaji. The only way to get others (like Hiragana and Katakana) back is to restart Firefox. It seems visiting certain web sites may trigger it, but don't know exactly. Why is this happening?
    It started from one of these and their links:
    http://www.yamatoamerica.com/
    http://www.ocsworld.com/
    http://www.dhl.com/
    I tried to recreate the situation, but couldn't. I will report back if I find one that triggers.

    You can check for issues caused by plugins (plugins are not affected by Safe mode).
    *https://support.mozilla.org/kb/Troubleshooting+plugins
    You can check for problems with current Flash plugin versions and try these:
    *disable a possible RealPlayer Browser Record Plugin extension for Firefox and update the RealPlayer if installed
    *disable protected mode in Flash 11.3 and later
    *disable hardware acceleration in the Flash plugin
    *http://kb.mozillazine.org/Flash#Troubleshooting

  • How to set max length to textfield?

    I have a textfield. I want to set maxlength to this textfield. Example, length = 3.
    Help me?

    I succeeded. That link you sent very well. Thanks you. Then it's code:
    JTextFieldLimit.java
    import javax.swing.text.*;
    //import com.sun.java.swing.*;
    //import javax.swing.text.*;
    public class JTextFieldLimit extends PlainDocument {
       private int limit;
       // optional uppercase conversion
       private boolean toUppercase = false;
       JTextFieldLimit(int limit)
        super();
        this.limit = limit;
       JTextFieldLimit(int limit, boolean upper) {
        super();
        this.limit = limit;
        toUppercase = upper;
       public void insertString
         (int offset, String  str, AttributeSet attr)
           throws BadLocationException {
        if (str == null) return;
        if ((getLength() + str.length()) <= limit) {
          if (toUppercase) str = str.toUpperCase();
          super.insertString(offset, str, attr);
    tswing.java
    import java.awt.*;
    import javax.swing.*;
      //import javax.swing.*;
      public class tswing extends JApplet{
        JTextField textfield1;
        JLabel label1;
        public void init() {
          getContentPane().setLayout(new FlowLayout());
          label1 = new JLabel("max 10 chars");
          textfield1 = new JTextField(15);
          getContentPane().add(label1);
          getContentPane().add(textfield1);
          textfield1.setDocument
             (new JTextFieldLimit(10));
    TextField.html
    <html>
    <applet code=tswing width=500 height=500>
    </applet>
    </html>
    By tungld_c0701m+

  • PL/SQL Function to convert fields & set max length

    I am having a problem with the following assignment:
    Write a stored PL-SQL function called namefct that will convert two varchar2 fields (first and last names) into the format: lastname, firstname with a maximum length of 10 chars. If the combined size of the two names is greater than 10 characters, you will issue an error message indicating the name has been shortened to 10 characters and return only the first ten characters, otherwise return the entire name. Test the namefct function by using the staff table created in Part 1 (above). Turn in: the SQL statements to build the function, execute the sample code and the resulting output.
    This is the start of my attempt, excluding the error message that is to be issued:
    CREATE OR REPLACE FUNCTION namefct (fname VARCHAR2, lname VARCHAR2) IS
    BEGIN
    column "full name" format a10;
    SELECT namefct(fname, lname) as "full name" from staff;
    END namefct
    Any advice or assistance would be greatly appreciated, since my Professor seems unwilling to assist me. Thanks!

    Write a stored PL-SQL function called namefct that
    will convert two varchar2 fields (first and last
    names) into the format: lastname, firstname with a
    maximum length of 10 chars. If the combined size of
    the two names is greater than 10 characters, you will
    issue an error message indicating the name has been
    shortened to 10 characters and return only the first
    ten characters, otherwise return the entire name.
    Test the namefct function by using the staff table
    created in Part 1 (above). Turn in: the SQL
    statements to build the function, execute the sample
    code and the resulting output.Firstly you need to consider what you have already been taught as you need to ensure that you code your function according to the purpose of the assignment. i.e. are you supposed to be demonstrating the use of returning values in a function or are you supposed to be demonstrating the use of exception handling etc.
    The main tricky bit with this assignment is the requirement to show an error message and still return a value. If you were to just raise an exception with the error message (e.g. raise application error) then you won't be able to actually return a value. Because it's a function and not a procedure that has been specified you aren't returning the value in an OUT parameter which would have made passing the value back and raising an exception easier.
    So, the only real way to have a function and allow it to show an error message would be something like...
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE FUNCTION f_name(p_forename IN VARCHAR2, p_surname IN VARCHAR2) RETURN VARCHAR2 IS
      2    name_too_long EXCEPTION;
      3  BEGIN
      4    IF LENGTH(p_surname||', '||p_forename) > 10 THEN
      5      RAISE name_too_long;
      6    END IF;
      7    RETURN p_surname||', '||p_forename;
      8  EXCEPTION
      9    WHEN name_too_long THEN
    10      DBMS_OUTPUT.PUT_LINE('Name Too Long. Truncating to 10 chrs.');
    11      RETURN SUBSTR(p_surname||', '||p_forename, 1, 10);
    12* END;
    SQL> /
    Function created.
    SQL> select f_name('FRED','SIMS') from dual;
    F_NAME('FRED','SIMS')
    SIMS, FRED
    SQL> select f_name('FRED','SIMKINSON') from dual;
    F_NAME('FRED','SIMKINSON')
    SIMKINSON,
    Name Too Long. Truncating to 10 chrs.
    SQL>Note: Tutors/Professors are very wise to checking your work on the internet to make sure it hasn't been copied, so I would suggest you don't just copy this verbatim, but actually read it and understand how it's working and write your own version, taking account of what you have been taught so far and not using things you haven't been taught.
    ;)

  • Flash Builder 4.6 code hinter problem - not showing some methods

    Hi All,
    I have a problem with FB code hinter. It does not show some methods on an object.
    To be exact I created a Date object and FB code hinter does not show .toDateString method (actually I it shows only one to string method - .ToString(), although according to docs there are more)
    When I use .toDateString method, code still compiles and work just fine, however method is not showing up in code hinter, which is really annoying..
    Anyone had this problem? If so, please, share some wisdom how to solve this thing.
    Thanks in advance.
    UPDATE:
    Here is some more info in my problem.
    I have tried to reinstall the application, but it did not help.
    So what I did was:
    * first I installed FB standard edition version 4.
    * I checked the code hinter and it worked. It showed .toDateString method.
    * I have purchased FB standard 4.5 upgrade.
    * I installed this upgrade, and boom the code hinter does not show the method...
    * Next I tried to create a project with Flex 4.1 sdk and then it worked - method was there. So the problem is with 4.6 sdk apparently...sucks...

    Hi, I have the same problem. I have a new FB 4.6 installation and it is my first FB installation. Do you have a solution already?

  • Pagination disappears after setting 'max row count'

    I have a report with app. 4500 records (with the default of 15 lines per page) and a pagination scheme of 'Row Ranges 1-15 16-30 in select list (with pagination)'.
    When running the report, all is working fine and i get the information in the select list '.. of more than 500'.
    Then i inserted some values in the 'max row count'-field:
    a value of 2000: it's working as expected
    a value of 4000 (or more): the pagination disappears and won't be desplayed :-(
    Any ideas, what i have done wrong?
    Thanks
    Rainer

    Hi
    This problem - select list dissapearing when > 32k still persists in Version 3.
    A neat workaround is to use a page item to set the number of rows disaplyed.
    Where there is a large number of rows in the table and the max rows is also large, simply set the page item value for the number of rows to a larger value say 200 - then - if the select list now becomes less than 32K the select list will be shown.
    It's a matter of balancing the number of rows shown on the page with the total number of rows in the table / max rows combination.
    It's not perfect but it works.
    Hope this helps.
    Mike Mac
    Message was edited by:
    Mike Mac

  • Getting the max length

    i am using pl/sql and i need to do some validation regarding the max length of the string. but the problem is that i have to refer back to the database for the length so that if the database change, my code don't change.
    is there any way to get the max length in the field of the table?
    eg:
    lets say i got a table call Person with column Name(varchar2(66)) and Sex(char(1))
    so how i retrieve the max length of the field Name?
    thanks

    It's quite simple. We can use the PL/SQL %TYPE in our declarations. Check it out...
    SQL> CREATE TABLE small1 (col1 NUMBER, col2 VARCHAR2(3))
      2  /
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE small1_api (pv_string IN VARCHAR2)
      2  AS
      3      l_col2 small1.col2%TYPE;
      4  BEGIN
      5      l_col2 := pv_string;
      6      INSERT INTO small1 (col1, col2)
      7      VALUES (a12.NEXTVAL, l_col2);
      8  EXCEPTION
      9      WHEN value_error THEN
    10          dbms_output.put_line('oops! string is too long');
    11  END;
    12  /
    Procedure created.
    SQL> EXEC small1_api('APC')
    PL/SQL procedure successfully completed.
    SQL> EXEC small1_api('APC4')
    oops! string is too long
    PL/SQL procedure successfully completed.
    SQL>
    SQL> ROLLBACK
      2  /
    Rollback complete.
    SQL> ALTER TABLE small1 MODIFY (col2 VARCHAR2(4))
      2  /
    Table altered.
    SQL> ALTER PROCEDURE  small1_api COMPILE
      2  /
    Procedure altered.
    SQL>
    SQL> EXEC small1_api('APC4')
    PL/SQL procedure successfully completed.
    SQL> EXEC small1_api('APC45')
    oops! string is too long
    PL/SQL procedure successfully completed.
    SQL> Cheers, APC

  • My mail app on I phone 4s crashes every time when i try to open, and i can see it thru the setting general. also phone is overheating and spending battery fast. does any one has some answer on this or same issue? what to do didi any has same issue?

    my mail app on I phone 4s crashes every time when i try to open, and i can see it thru the setting>general. also phone is overheating and spending battery fast. does any one has some answer on this or same issue? what to do did any has same issue? if i do an complete phone restore what will hapend ?

    You can call Verizon to replace it or go to an applestore to replace it since it won't even power on with multiple chargers.

  • Why Set does not have get() method

    Can some one tell me why set does not have get method?...

    user12203354 wrote:
    ya u are right that designer of this class thought there is no implementation required for get but why he/she thought like this...
    there must be some valid reason for the same.Because a Set's purpose is not to keep things in order; it's to ensure there are no duplicate entries. Set would require extra code to be able to keep track of an order.
    Note that there is a Set implementation that does keep track of insertion order--LinkedHashSet--but it doesn't have a get() method.

  • Does WebDynPro have finalizer method for some ojects?

    I need to create object pool with guaranteed  call to destroy participated objects (DB Sessions) after end of some method execution,
    or owning object release.
    Does WebDynPro has such a method?
    How to implement it?
    thanks

    OK, very  thanks , that answer was presented on most seen place,
    (not always seen).
    what is unteresting - does it really guarranteed to be called?
    Happen at all experiments - is not "guarranteed".
    Are there any else ways?

Maybe you are looking for

  • Will Adobe Reader 7.0.9 or 7.1.0 work with Content Server 4?

    Hello Adobe, I have a Toshiba Satellite A75-S213 laptop, Intel Pentium 4, 1 GB RAM, Windows XP Home. I've purchased ebooks from SimonSays.com several times over the course of 2008; each time, my Adobe Reader 7.0.9 was able to open the "ebx.etd" file

  • Dell XPS 13 (2015) - Windows 7/8.1 Dual Boot Audio Issue

    Specs:  I have the i5 FHD XPS 13 9343 with 8gb of ram and 256gb SSD. I bought the computer for dual personal and business purposes.  My company uses citrix to access virtual desktops and the security requirements are Windows 7/IE 9.  Upon purchase, I

  • File Adapter with Linux

    Hi I want to send file from linux server to XI File Adapter I cannot cr8 nfs between them ( our XI is running on AIX) there's an option of Using samba client ( which works likes FTP ) does XI Supports that option? other thing i have been thiking on i

  • HT4759 how do i authorize my computer so that i can download my previous purchase

    how do i authorize my computer so that i can download my previous purchase

  • KDM Won't Launch

    Hi guys, New Arch user here. I just finished setting up a base system and have Xorg installed.  Now I'm trying to setup KDE.  I installed the full KDE package and are trying to launch KDM. When I launch STARTX I'm taken into the default Xorg window m