I want to create decimal number formated text field

hi
I am trying to create decimal for eg 1234.20
only this type number can acssess
for that what I do

try adding a CustomKeyListener to your text component....
to create decimal for eg 1234.20((JTextComponent)component).addKeyListener(CustomKeyListener(4,2));
import java.awt.event.*;
import javax.swing.text.JTextComponent;
public class CustomKeyListener extends KeyAdapter {
     char separator = '.';
     // total digits allowed
     int maximumSize ;
     // digits before the separator
     int before = -1;
     // digits after the separator
     int after = -1;
     public CustomKeyListener(int the_before,int the_after) {
          before = the_before;
          after = the_after;
          maximumSize = before+after+1;
     public void keyTyped(KeyEvent e){
          JTextComponent txtComp = (JTextComponent) e.getSource();
          if (txtComp.getText().length() < maximumSize ){
               if(Character.isDigit(e.getKeyChar())||
                         e.getKeyCode() == KeyEvent.VK_BACK_SPACE||
                         e.getKeyChar() == separator ||
                         e.getKeyChar() == ',') {
               // if txtComp contains a separator
                    if (txtComp.getText().indexOf(",") != -1 ||
                         txtComp.getText().indexOf(".") != -1     ){
               // a second separator (if typed) will be deleted
                              if (e.getKeyChar() == separator ||
                                             e.getKeyChar() == ',')     {
                              e.setKeyChar(new Character('\b'));
                              return;
               // typed a digit
                         int separatorPosition;     
                         if (txtComp.getText().indexOf(",") != -1 ){                         
                              separatorPosition =txtComp.getText().indexOf(",");
                         else{                         
                              separatorPosition =txtComp.getText().indexOf(".");
                         // finding caret position
                         int cp = txtComp.getCaretPosition();
//                         System.out.println("posizione del caret " + cp);
               // caret before separator
                         if ( cp <= separatorPosition ){
                              if (txtComp.getText().
                                        substring(0,separatorPosition).trim().length()<
                                        before){     
                                   return;
                              else{                              
                                   e.setKeyChar(new Character('\b'));
                                   return;          
                         else{
                         // caret after separator
                              if (txtComp.getText().
                                        substring(separatorPosition+1).length()<
                                        after){     
                                   // digit is ok!
                                   return;
                              else{
                                   e.setKeyChar(new Character('\b'));
                                   return;
                    else{
                    // separator absent
                         // if is typed a separator
                         if (e.getKeyChar() == separator ||
                         e.getKeyChar() == ','){
                              int cp = txtComp.getCaretPosition();
                              if (txtComp.getText().length() - cp-1 < after){
                                   return;
                              else{
                                   e.setKeyChar(new Character('\b'));
                                   return;
                         // is typed a digit
                         else{                              
                              if(txtComp.getText().trim().length()<before){
                                   return;
                              else{
                                   e.setKeyChar(new Character('\b'));
                                   return;
               }else{
                    // the key pressed isnt numeric
                    if (Character.getNumericValue(e.getKeyChar())!=-1)
                    e.setKeyChar(new Character('\b'));
                    return;
          else{
               // Maximum lenght reached
               e.setKeyChar(new Character('\b'));
}

Similar Messages

  • How to create Using Formatted Text Field with multiple Sliders?

    Hi i found the Java Sun tutorial at http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html very useful, and it tells how to create one Formatted Text Field with a Slider - however i need to create Formatted Text Field for multiple Sliders in one GUI, how do i do this?
    my code now is as follows, and the way it is now is scroll first slider is okay but scrolling second slider also changes value of text field of first slider! homework due tomorrow, please kindly help!
    // constructor
    label1 = new JLabel( "Individuals" );
    scroller1 = new JSlider( SwingConstants.HORIZONTAL,     0, 100, 10 );
    scroller1.setMajorTickSpacing( 10 );
    scroller1.setMinorTickSpacing( 1 );
    scroller1.setPaintTicks( true );
    scroller1.setPaintLabels( true );
    scroller1.addChangeListener(this);
    java.text.NumberFormat numberFormat = java.text.NumberFormat.getIntegerInstance();
    NumberFormatter formatter = new NumberFormatter(numberFormat);
            formatter.setMinimum(new Integer(0));
            formatter.setMaximum(new Integer(100));
    textField1 = new JFormattedTextField(formatter);
    textField1.setValue(new Integer(10)); //FPS_INIT
    textField1.setColumns(1); //get some space
    textField1.addPropertyChangeListener(this);
    //React when the user presses Enter.
    textField1.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),  "check");
            textField1.getActionMap().put("check", new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                    if (!textField1.isEditValid()) { //The text is invalid.
                        Toolkit.getDefaultToolkit().beep();
                        textField1.selectAll();
                    } else try {                    //The text is valid,
                        textField1.commitEdit();     //so use it.
                    } catch (java.text.ParseException exc) { }
    label2 = new JLabel( "Precision" );
    scroller2 = new JSlider( SwingConstants.HORIZONTAL, 0, 100, 8 );
    scroller2.setMajorTickSpacing( 10 );
    scroller2.setMinorTickSpacing( 1 );
    scroller2.setPaintTicks( true );
    scroller2.setPaintLabels( true );
    scroller2.addChangeListener(this);
    textField2 = new JFormattedTextField(formatter);
    textField2.setValue(new Integer(10)); //FPS_INIT
    textField2.setColumns(1); //get some space
    textField2.addPropertyChangeListener(this);
    //React when the user presses Enter.
    textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),  "check");
            textField2.getActionMap().put("check", new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                    if (!textField2.isEditValid()) { //The text is invalid.
                        Toolkit.getDefaultToolkit().beep();
                        textField2.selectAll();
                    } else try {                    //The text is valid,
                        textField2.commitEdit();     //so use it.
                    } catch (java.text.ParseException exc) { }
    // State Changed
         public void stateChanged(ChangeEvent e) {
             JSlider source = (JSlider)e.getSource();
             int fps = (int)source.getValue();
             if (!source.getValueIsAdjusting()) { //done adjusting
                  if(source==scroller1)   {
                       System.out.println("source ==scoller1\n");
                       textField1.setValue(new Integer(fps)); //update ftf value
                  else if(source==scroller2)     {
                       System.out.println("source ==scoller2\n");
                       textField2.setValue(new Integer(fps)); //update ftf value
             } else { //value is adjusting; just set the text
                 if(source==scroller1)     textField1.setText(String.valueOf(fps));
                 else if(source==scroller2)     textField2.setText(String.valueOf(fps));
    // Property Change
        public void propertyChange(PropertyChangeEvent e) {
            if ("value".equals(e.getPropertyName())) {
                Number value = (Number)e.getNewValue();
                if (scroller1 != null && value != null) {
                    scroller1.setValue(value.intValue());
                 else if (scroller2 != null && value != null) {
                    scroller2.setValue(value.intValue());
        // ACTION PERFORMED
        public void actionPerformed(ActionEvent event) {
        if (!textField1.isEditValid()) { //The text is invalid.
            Toolkit.getDefaultToolkit().beep();
            textField1.selectAll();
        } else try {                    //The text is valid,
            textField1.commitEdit();     //so use it.
        } catch (java.text.ParseException exc) { }
             if (!textField2.isEditValid()) { //The text is invalid.
            Toolkit.getDefaultToolkit().beep();
            textField2.selectAll();
        } else try {                    //The text is valid,
            textField2.commitEdit();     //so use it.
        } catch (java.text.ParseException exc) { }
    ...

    if :p3_note_id is null
    then
    insert into notes (project_id, note, notes_month, notes_year) So, p3_note_id is NULL.
    Another option is that you have a trigger on table NOTES that generates a new note_id even for an update.

  • Formatted Text field for File Extensions

    Hi guys,
    Is it possible to create formatted text field for file extension like it should accept *.bmp, .bmp, bmp. etc..... It is not necssary to be a Combo Box. TextField will work.
    Thanks in advance.
    AZGHAR

    Any one here \Help\Help\Help ;-(

  • How to create a custom shape text field?

    I have a diamond shape movieClip and I need add a text Field in the same shape format.
    Now how to create a diamond shape text field?
    Please help me!
    Thanks,
    Jafy

    there's no easy way to do that in flash.  that's an advanced task.

  • How to create pdf files with text field data

    how to create pdf files with text field data

    That looks like it should work, but it doesn't.
    I opened the PDF I had created from Word in Acrobat (X Pro). Went to File > Properties. Selected "Change Settings". I then enabled "Restrict editing...", set a password, set "Printing Allowed" to "none", "Changes Allowed" to "none", and ensured that "Enable copying of text..." was disabled.
    I saved the PDF file, closed Acrobat, opened the PDF in Reader, and I was still able to select text and graphical objects.
    I reopened the PDF in Acrobat, and the document summart still shows everything as allowed. When I click on "show details" (from File > Properties) it shows the correct settings.
    Any ideas?

  • Formatted Text Field for getting Date

    I need a text field to get Date. does anyone know where I can find such a thing?
    all it needs to do is allow the user to type a date in dd/MM/yy format.
    10x.

    in a jtable it has a problem - when I press tab to exit the field the date is not changed.
    i set the on focus lost behaviour to commit, but still not working.
    also, it allows me to enter 4823749823/02/02 - and it translates it to the right format - I'm interested in something more fixed - allows to enter only 2 digits for day, 2 digits for month,2 digits for year.
    the relevent code I'm using is:
    // a cellEditor that uses a formatted text field that holds a Date object
    public class JFormattedDateCellEditor extends DefaultCellEditor {
    public JFormattedDateCellEditor(final JFormattedTextField textField) {
    super(textField);
    textField.setFocusLostBehavior(JFormattedTextField.COMMIT);
    textField.setHorizontalAlignment(SwingConstants.RIGHT);
    textField.setFont(JUtility.theFont);
    textField.setBorder(null);
    textField.addFocusListener(new FocusAdapter() {
    public void focusLost(FocusEvent e) {
    if (textField.getValue() == null) {
    textField.requestFocus();
    delegate = new EditorDelegate() {
    public void setValue(Object value) {
    textField.setValue((java.util.Date)value);
    public Object getCellEditorValue() {
    return textField.getValue();
    //to set the cell editor:
    column = collectionsTable.getColumnModel().getColumn(CollectionFrame_collectionsModel.DATE_COLUMN);
    column.setCellEditor(
    new JFormattedDateCellEditor(
    new JFormattedTextField(
    new DateFormatter(
    new SimpleDateFormat("dd/MM/yy")))));

  • How do you create animation on website i.e. i just want to create a simple moving text in my site.

    I just want to create a moving text or a flashing text in my website using iWeb. HELP!

    See the bgcolor= ?  That's the background color.  In the iWeb color inspector window chose the web safe color palette, and you will see the number codes that correspond to the colors. just type in the numbers you want and that will change the background color.
    Sincerely,  David

  • How to create an "L" shaped text field

    I need to insert a text field in an Acroform with a label that starts part way in on one line and then continues on the next line, as shown below.
    Is it possible to insert an L-shaped text field? If not, is it possible to automatically move the text cursor to the next field when the person filling out the form runs out of space on the first line? I'm using Acrobat XI Pro on Windows 7.

    Actually if you create the form in a Third pary Program called FileMaker  It allows you when you create the field  you can insert the title of the field (which is the same as the Field name) either to left side or above. Then when PDF is created Even though its rectangular shape it will show with question or what ever above the actual acrea that will be filled out.
    Or you can use Word
    In word you
    Create on each line item and set tab for proper distance of each item on line.
    Then go to Format Tabs and set each tab to show underline.
    hit tab just at end of title.
    Set ine spacing to 1.5 or 2
    Next hit return and hit tab number times
    Repeat with each line you may have to readjust tabs in Tab format or drag tab marker in top ruler to desired spacing.
    Hit retun and and hit desired number of spaces
    When finished seting up Form go back to first line with text
    Go to tab format and remove the underline hit set if you have more than one line. When finished hit okay.
    Go to next line with text and repeat removal of underline.
    When finished you should have line that have text only
    And, just bellow lines on spaced so the start just under the text above.
    Now go to Print Menu > PDF > choose Adobe PDF.
    Open in Acrobat in tools click Forms > Create form
    Choose current document
    Then choose to use current document again.
    When finished  The Form fields should be Properly named.
    Edit each field appropriately whether for text or Numbers or Phone numbers or zip codes
    Save under a different name.
    Here are samples:
    http://www.4shared.com/download/RIbUOSnjce/Microsoft_Word_-_Last_Namedocx.pdf Created by Word
    http://www.4shared.com/download/z0Yj9Ouoba/Untitled2.pdf Created with FileMaker.
    If you ever want to change form in version created by word and just retype text as desired
    print as PDF under different name.
    Either recreate fields, or if your just changing spelling or added additional text but didn't cahge what it its, choose Replace pages.

  • Adding user-defined number of text fields.

    Okay I am having problems, obviously. I am developing a program where the user will enter X and Y values and the program will calculate the relational data. However, I can't even get a start.
    First of all, the user defines the number of pairs of points they want to define. For example, they have 20 points, each with its own X and Y, so they click on 20 and then okay in the first window.
    The next window will then take their answer and display X and Y text fields for as many points as they defined. However, I can't figure out any way to do this.
    Feel free to run the program, the problem lies in the method setTextFields(). Help please!
    import javax.swing.*;               //FOR SWING COMPONENT CLASSES
    import java.awt.*;                  //FOR CONTAINER CLASS
    import java.awt.event.*;            //FOR EVENT HANDLING
    public class RegressInput extends JFrame
        private JComboBox listJComboBox;        //COMBO BOX TO HOLD HOW MANY PAIRS OF DATA POINTS THE USER HAS TO ENTER
        private JButton answerButton;           //BUTTON TO CLICK AFTER SELECTING PAIRS OF DATA POINTS
        private JPanel textFieldTopPanel;       //TEXT FIELD TOP PANEL
        private JPanel textFieldBottomPanel;    //TEXT FIELD BOTTOM PANEL
        private JPanel textFieldPanel;           //TEXT FIELD PANEL   
        private CardLayout cardSelector;        //DECLARE CARD LAYOUT OBJECT   
        private JPanel cardDeck;                //DECLARE CARD PANEL OBJECT
        public RegressInput(String title)
            super(title);               //CALL SUPERCLASS CONSTRUCTOR
            //CREATE A CONTAINER
            Container container = getContentPane();
            //INSTANTIATE CARD LAYOUT OBJECT
            cardSelector = new CardLayout();
            //INSTANTIATE PANEL OBJECT
            cardDeck = new JPanel();
            //SET LAYOUT OF CARD DECK PANEL TO CARD LAYOUT
            cardDeck.setLayout(cardSelector);
            //DEFINE LABEL FOR FIRST CARD
            Label question = new Label("How many PAIRS of data would you like to enter?");
            //BUTTON TO SUBMIT NUMBER OF POINTS TO PLOT
            answerButton = new JButton("OK");
            listJComboBox = new JComboBox( getArray() );//USE getArray() METHOD TO SET ITEM LIST OF THE COMBO BOX
            listJComboBox.setMaximumRowCount(10);       //SETS THE VISIBLE NUMBER OF ITEMS TO THE USER
            Label xValues = new Label("X Values");      //LABEL FOR X values
            Label yValues = new Label("Y Values");      //LABEL FOR Y values
            //BUILD CARD DECK
            JPanel comboBoxCard = new JPanel();     //CREATE FIRST CARD
            comboBoxCard.add(question);             //ADD question LABEL TO FIRST CARD
            comboBoxCard.add(listJComboBox);        //ADD listJComboBox TO FIRST CARD
            comboBoxCard.add(answerButton);         //ADD answerButton TO FIRST CARD
            textFieldTopPanel = new JPanel();       //CREATE TOP PANEL OF SECOND CARD
            textFieldTopPanel.add(xValues);         //ADD xValues Label TO SECOND CARD
            textFieldTopPanel.add(yValues);         //ADD yValues Label TO SECOND CARD
            textFieldBottomPanel = new JPanel();    //CREATE BOTTOM PANEL OF SECOND CARD
            textFieldBottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));    //SET LAYOUT FOR BOTTOM PANEL
            textFieldPanel = new JPanel();          //CREATE PANEL FOR SECOND CARD
            textFieldPanel.setLayout(new BorderLayout(10, 10)); //SET LAYOUT FOR SECOND CARD
            textFieldPanel.add(textFieldTopPanel, "North"); //ADD textFieldTopPanel TO NORTH
            textFieldPanel.add(textFieldBottomPanel, "South");  //ADD textFieldBottomPanel TO SOUTH
            cardDeck.add(comboBoxCard, "Step 1");       //ADD FIRST CARD TO DECK
            cardDeck.add(textFieldPanel, "Step 2");     //ADD SECOND CARD TO DECK
            container.add(cardDeck);                    //ADD CARD DECK TO CONTAINER
            //DEFINE BUTTON HANDLER OBJECT
            ButtonHandler buttonHandler = new ButtonHandler();
            //ADD ACTION LISTENER FOR BUTTONS
            answerButton.addActionListener(new ButtonHandler());
        }//END RegressInput() CONSTRUCTOR
        //METHOD TO CREATE AND RETURN AN ARRAY OF VALUES FOR JComboBox
        private String[] getArray()
            //CREATE ARRAY TO HOLD 30 VALUES
            int numbers[] = new int[29];
            //CREATE int IN ORDER TO START THE ARRAY AT 2 INSTEAD OF 1
            int number = 2;
            //ASSIGN VALUES FROM 2 TO 30 TO numbers[] ARRAY
            for(int count=0; count < 29; ++count)
                numbers[count] = number;        //SETS EACH INDEX TO number
                number++;                       //INCREMENTS number
            }//END for LOOP
            //CREATE pairs[] ARRAY TO HOLD 30 STRINGS
            String pairs[] = new String[29];
            //ASSIGN VALUES 1 TO 30 IN STRING ARRAY FOR COMBO BOX
            for(int count = 0; count < 29; ++count)
                pairs[count] = "" + numbers[count];
            }//END for LOOP
            return pairs;//RETURNS pairs[] ARRAY FOR THE LIST ITEMS IN listJComboBox
        }//END getArray() METHOD8
        //RETURNS THE ITEM SELECTED BY THE USER FROM THE JComboBox
        private int getValue()
            //ASSIGNS STRING VALUE OF THE JComboBox TO A WRAPPER
            Integer v = new Integer((String) listJComboBox.getSelectedItem());
            //ASSIGNS WRAPPER VALUE TO int
            int value = v.intValue();
            //RETURN VALUE OF SELECTED ITEM
            return value;
        }//END getValue()
        private void setTextFields()
        {//HERE LIES THE PROBLEM! WHAT GOES IN THIS METHOD????
            for(int count = 0; count < (2 * getValue()); ++count)
        }//END setTextFields()
        //BUTTON EVENT HANDLER CLASS
        private class ButtonHandler implements ActionListener
         //PROCESS EVENT
            public void actionPerformed(ActionEvent e)
                //WHICH BUTTON CAUSED THE EVENT?
                if(e.getSource() == answerButton)
                    cardSelector.last(cardDeck);
                    cardDeck.setSize(600,600);
                }//END if STATEMENT
            }//END actionPerformed()
        }//END ButtonHandler CLASS
    }//END RegressInput CLASSHere is main:
    import javax.swing.JFrame;
    public class TestSharpStats
         public static void main(String[] args)
            //DEFINE FRAME OBJECT
            RegressInput window = new RegressInput("Hi");     //SETS TITLE BAR
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      //CLOSES WINDOW
            window.setSize(400, 600);    //SET FRAME SIZE
            window.setResizable(true);  //PREVENTS USER FROM RESIZING WINDOW
            window.setVisible(true);     //SETS window TO VISIBLE
        }//END main()
    }//END TestSharpStats CLASS

    muit-post: http://forum.java.sun.com/thread.jspa?messageID=4442652

  • Create survey/poll with text fields

    I want to create a survey in a meeting with text field type answers.  How would I do this?  I am using the hosted version of Connect and saw some reference to a Presenter add-in for PowerPoint, but don't seem have that.  We would like to have fields such as:
    Participant information (name, contact information
    Suggested future topics
    What should I use to do this since the Poll Pod obnly allows for multiple choice or multiple answer options and not key-in fields?
    Karl

    Adobe Presenter 7 is a product sold separately from Adobe Connect. Adobe Presenter can be purchased from many resellers.  It is a plug-in for MS Powerpoint and has the ability to upload many times of quizzes and polls in lots of types of formats.  You can download a 30 day trial from here:
    http://www.adobe.com/cfusion/tdrc/index.cfm?product=presenter&loc=en_us
    Adobe Presenter is only available for the Windows platform. MS Powerpoint for Mac does not allow third-party plug-ins like Presenter.

  • Formatted Text Field

    I have a text field that I want the user to be able to enter up to 4 numbers. I tried a mask formatter using the "####" format, but that forces the user to enter 4 numbers. I want them to be able to enter, 1,2,3 or 4 numbers.

    Hi,
    I've implemented number fields based on JFormattedTextField.
    They also support a min and a max value.
    Maybe you find them useful (the library is open source):
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JRealNumberField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JDoubleField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JFloatField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedRealNumberField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedDoubleField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedFloatField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JWholeNumberField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JByteField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JIntegerField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLongField.html
    http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JShortField.html
    Tutorial:
    http://softsmithy.sourceforge.net/lib/docs/tutorial/swing/number/index.html
    Homepage:
    http://www.softsmithy.org
    Download:
    http://sourceforge.net/project/showfiles.php?group_id=64833
    Source:
    http://sourceforge.net/svn/?group_id=64833
    http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/
    -Puce

  • HELP!! How do I create hyperlink in a text field?

    Hi!
    I've been going through the message boards and I am not finding my answer.  I have created a form utilizing LiveCycle.  I have made the form so that it can be fillable via Reader Extended PDF.  I need to be able to put a link in a text field that the next user can just click on it, and it will take them to a document in SharePoint for review.  I've tried changing the text field to rich text in LiveCycle, but the steps to add the link in the PDF is too lengthly and not friendly.  Once I finally get it to put the link in, the end user cannot just click on it.  They have to take additional steps.  Someone on the boards mentioned something about putting a button next to the field that will convert the text of the link in the previous text field to a link, but I cannot find those instructions or understandable instructions.  The management wants it to be where you just click on the link.  How do I do this?  I am not a techie, so I need instructions in layman's terms.
    PLEASE HELP!
    Thank you!
    Maribeth

    I'm in the same boat as you, inasmuchas I taught myself LC. I've tried to replicate your issue. I'm trying to understand where the issue actually lies.
    First, I created a new document to test. I dragged the text field onto the document and stretched it to accomodate what I was going to type and entered: http://www.google.com/something
    This works as intended.
    Next I tried a link similar to yours in our own intranet: http://intranet/WebPages/support.aspx
    That also worked.
    Now, for what you're actually working with: a SharePoint document.
    I tried to paste a link to a document that I created on our Sharepoint site. The link failed! I noticed that the end of the link was truncated (something like 7 characters). So, I tried a shorter link. That worked!
    What else is happening when they click the link? Are they simply being asked to "check out" the document? Are you getting an error message like "an error has occured while opening the page"?
    Message was edited by: jasotastic81 (apparently "lnik" is not a word)

  • Batch process to create large number of metadata fields in UCM?

    Is there any kind of scripting available to create a large number of metadata fields in UCM?.
    thanks

    I can give you a code in java, which adds two metadata fields. It's quite hardcoded, but you could use it as a basis for a script:
    String FIELD1_NAME = "xsecretKey";
    String FIELD2_NAME = "xattachmentID";
    if (binder == null)
    binder = new DataBinder(SharedObjects.getSafeEnvironment());
    String maxOrderQuery = "select MAX(dOrder) as dOrder from DocMetaDefinition";
    try
    String val = loader.getDBConfigValue(COMPONENT_NAME, COMPONENT_SUBNAME, null);
    //binder.putLocal("dName", FIELD1_NAME);
    binder.putLocal("dName", FIELD2_NAME);
    ResultSet tempRs = ws.createResultSet("Qmetadef", binder);
    if (val == null || tempRs.isEmpty())
    ResultSet rset = ws.createResultSetSQL(maxOrderQuery);
    String orderStr = ResultSetUtils.getValue(rset, "dOrder");
    int order = NumberUtils.parseInteger(orderStr, 0);
    setNewFieldParams(binder, "BigText", "secretKey", "<$dateCurrent()*1$>");
    addNewMetadataField(FIELD1_NAME, binder, ++order, null, null, ws, cxt);
    setNewFieldParams(binder, "Text", "attachmentID", null);
    addNewMetadataField(FIELD2_NAME, binder, ++order, null, null, ws, cxt);
    rset = ws.createResultSetSQL("select * from DocMeta where dID=0");
    if (!testResultSetFieldExists(rset, FIELD1_NAME))
    FieldInfo fi[] = loader.createFieldInfo(new String[] {
    FIELD1_NAME
    }, 200);
    //fi[0].m_type = 5;
    ws.alterTable("DocMeta", fi, null, new String[] {
    "dName"
    if (!testResultSetFieldExists(rset, FIELD2_NAME))
    FieldInfo fi[] = loader.createFieldInfo(new String[] {
    FIELD2_NAME
    }, 30);
    //fi[0].m_type = 3;
    ws.alterTable("DocMeta", fi, null, new String[] {
    "dName"
    loader.setDBConfigValue(COMPONENT_NAME, COMPONENT_SUBNAME, "7.0", "1");
    catch (Exception e)
    SystemUtils.dumpException(null, e);
    }

  • Need help formatting text field default value

    Hello,
    I've received a customer request to put default text into the Value section of a text field. They're requesting that the default text include line breaks, bullets, etc. I added a Text Field object and added the default text to the Object tab > Value tab Default field but can't figure out how to add line breaks, etc.
    Thanks in advance,
    Saskia

    Hi,
    this is possible but not doable with the UI of Designer.
    The workaround is as follows:
    1. Create a text, enter your default text with all the formattings you need (text color, bold text, line breaks etc.)
    2. Create a text field and enter any word as default value. Let's say "Default".
    3. Select the text and the switch to the XML Source view.
    There you will find all the formatted text between the <value> tags such as:
    <value>
         <exData contentType="text/html">
              <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p style="letter-spacing:0in">This is<span style="xfa-spacerun:yes"> </span></p><p style="color:#ff0000;letter-spacing:0in">default Text</p><p style="letter-spacing:0in"><span style="xfa-spacerun:yes"> </span>• with<span style="xfa-spacerun:yes"> </span><span style="font-weight:bold">RichText</span> formatting.</p></body>
         </exData>
    </value>
    4. Select the whole code between the <value> tags and copy it to the clipboard (ctrl + c).
    5. Go to the Design View, select the text field, go back to the XML Source view.
    6. There you'll also find the value <tags> and your default value you entered before.
    <value>
         <text>Default</text>
    </value>
    7. Select this code section and paste the value copied before to the clipboard by pressing ctrl + v.
    8. That's it. When you now go back to the Design View your text field shows a formatted RichText as defaul text.

  • Formatted Text Field Formats

    I have a FormattedTextField where the user inputs a decimal value. It works just fine, until the user deselects the field. At this point, if the value is <1 with three leading zeros (i.e. 0.0001), the field displays 0. The correct value is obtained from the text field, and it displays just fine when it's being edited, but the output is inaccurate.
    // I print via String valueOf to make sure the issue isn't at a String function, and it turns out okay
    console.printConsole(String.valueOf(a3));
    // I specify a formatter factory with my own object (defined below)
    // Since I use the same formatter object for the display, input, edit params, I would
    // think the way it is outputted wouldn't change across these, but it does
    label3 = new JLabel("i power " + 3 + " coefficient");
    field3 = new JFormattedTextField(new DefaultFormatterFactory(
    new CalFormatter(),
    new CalFormatter(),
    new CalFormatter()));
    // And I make sure there are enough columns to display the info
    field3.setValue(new Double(a3));
    field3.setColumns(10);
    // My cal formatter object
    class CalFormatter extends NumberFormatter{
    public CalFormatter(){
    super();
    // I manually call the valueOf String function in case that's where the loss of accuracy originates
    // ...no luck
    public String valueToString(double number) throws ParseException {
    return String.valueOf(number);

    what happens when you switch the lines to do the following:
    from this:
    field3.setValue(new Double(a3));
    field3.setColumns(10);
    to this:
    field3.setColumns(10);
    field3.setValue(new Double(a3));
    setColumns clears the field, so that may be your problem.

Maybe you are looking for

  • Cannot open database due to incorrect file size

    Hi, we have a oracle database 8.0.5 and it crashed yesterday. now we cannot open the database (only mount readonly) due to an incorrect filesize of usr1orcl.ora. is there a simple way to open the database?

  • Having this block coming up for java ,,TypeError: Components.classes[cid] is undefined what do i do to fix this issue

    while downloading fire fox it requested i update java,, which i did and upon doing so and restarting computer to have commponates installed ,,this error comes up and will not stop.. box heading JAVA SCRIPT APPLICATION WITH THIS MESSAGE....TypeError:

  • Flash Fullscreen Size Problem

    So, call me ridiculous, but I use 64 bit software whenever possible because I have a 64 bit OS with 64 bit CPU cores. Naturally, then, I use a 64 bit web browser: Firefox (nightly). This means I need a 64 bit version of flash which is still in a horr

  • Trying to remove connections and sessions

    I opened some sessionInfos which create a session in the database. When I remove those sessioninfos, I can see using Oracle DBA studio that the database sessions are hardly ever removed. How I can remove them by force. Thanks for your help

  • Sales order Creation date

    Hi All, I see that the sales order creation date in VBAK is suppose 2009.06.16 and in VA03 if i see th document flow the date is 2009.06.15. and quatation date is also 2009.06.15. Which date is the correct Sales order date.If va03 one is correct what