Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: How do you set default for form field dynamically?  (Read 9086 times)
Candy M.
Posts: 139


« on: October 25, 2008, 12:37:01 am »

We would like to set the default for a form field dynamically.

Are there any methods like   setFieldHidden(), etc?

We would like to search through DOM tree and set the default.

Any help is appreciated.

Thanks,
Candy
Sebastien F.
Four Js
Posts: 509


« Reply #1 on: October 27, 2008, 10:01:16 am »

Candy,

I let support people write you an example using the OM interface.
The attribute to be set is "defaultValue", in FormField, Matrix or TableColumn nodes.

Some questions:
- Why don't you use WITHOUT DEFAULTS option and set the field default values in program variables?
- Are you using multiple dialogs (DIALOG instruction)?

Seb
Candy M.
Posts: 139


« Reply #2 on: October 27, 2008, 08:29:29 pm »

Seb,
    We do use INPUT WITHOUT DEFAULTS now and set it in
program variables.
     What we would like to do is provide a utility so that user
can hide fields, activate/inactivate fields, and set their own
defaults.   I thought it might be easier setting the defaults
in the DOM tree and more general so that the code we use, we
could use everywhere and not depend on setting program
variables.

Candy
Sebastien F.
Four Js
Posts: 509


« Reply #3 on: November 01, 2008, 05:14:14 pm »

Candy, (sorry for the late answer)

I would not use the AUI tree to implement an application feature like customizable default values.

From my understanding, it's just a matter of default value storage.... right?

Why don't you just use a simple database table like:

CREATE TABLE user_defaults
(
   target_name VARCHAR(50) NOT NULL,
   user_name VARCHAR(50) NOT NULL,
   value VARCHAR(100),
   PRIMARY KEY (target_name, user_name)
)

And write some API around to get/set the values?

   CALL defaults_setValue("order.ord_state", user_name, "valid")
   LET rec_order.ord_state = defaults_getValue("order.ord_state", user_name, <default-default>)

The get function would need to interpret special values like TODAY, and return a default-default value if nothing found in table:

   SELECT value INTO p_value FROM user_defaults
        WHERE target_name = name AND user_name = uname
   IF SQLCA.SQLCODE == NOTFOUND THEN RETURN default_default END IF
   IF p_value == "TODAY" THEN RETURN TODAY END IF
   IF p_value == "CURRENT" THEN RETURN CURRENT END IF
   RETURN p_value

?

Seb
Candy M.
Posts: 139


« Reply #4 on: November 02, 2008, 06:06:55 am »

Thanks, Seb for your input.

When setting the values on the form, I wanted to
avoid having to set it to a program variable.  I thought
it would be nifty to have one function that I could call
and set the default values in the AUI tree instead of
having to set the program variables,  thus saving on
lots of code.

Candy

Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines