Custom form control function

I have followed the tut here:
with a couple modifications and I can’t get the setValue() function to work properly. Here is the custom form render:

return "<input name='sig' value='"+(config.value||0)+"' /><applet name='anesSigBlock' codebase='//inet/includes' code='SigBlock.class' archive='SigBlock.jar' width='301' height='76'></applet><anesSig><input type='button' value='Sign' onClick='saveThis()' /></anesSig>";

The java applet captures a signature, but I can’t figure out how to pass the sig data to the form control. I tried this:


but the data doesn’t show up when I call form.getValues(). I have also tried $$(‘form_5’).item(‘sig’).setValue(), but I get an undefined error. Any suggestions?


HA HA!!! I got it. The code below lets me set my Custom Form Control:

var sigdata = anesSigBlock.sign();

“sig” is the id of my custom form control. Now when I call form.getValues() my control actually shows data. Hopefully this will help someone else too.


However, I would still like to know how to access/use the setValue() and getValue of my custom components. Can someone show me a code snippet that demonstrates the correct usage? The tutorial only shows how to set it up.


Actually you can use your first approach as well

$$('form_5').refresh('sig'); //repaint with new value

but form.setValue is a better approach, because it just changes the value of the element, without full repainting ( which means - it works faster )

to know how to access/use the setValue() and getValue of my custom components
setValue and getValue methods of form element used by form.getValues|setValues calls

setValue method of form elements requires html node as one of parameters, so it is not very usable for direct scripting. It possible to call it directly but it will not have any advantages against form.setValues , or do you have some specific reasons for direct calls?

Now that I understand how setValues() works (thanks for the explanation) I doubt I will be calling setValue() and getValue() directly. Really I was just curious because I might want to add other functions to custom controls, but I can’t even figure out how to access the standard ones. Can you post a line of code with a html node that shows how to do it?


Something like next


textarea - type of input
form - owner form object

because it uses inner method ( _locateHTML ) it will work only with not compressed (_debug) version of code.