Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
FormAPI & cgi-callout question
System
Hello,
I have a text item in my DCT for storing a date which is entered using a cgi-callout. I've made this item read-only using:
var publish_dateItem = IWDatacapture.getItem("/publish_date");
publish_dateItem.setReadOnly(false);
When I change the value of this item using the callout, this is not directly shown on form so I suppose I need to redraw the form. To do this I registered an item handler:
IWEventRegistry.addItemHandler("/publish_date", "onItemChange", publishDateChange);
and implemented publishDateChange():
function publishDateChange(item)
{
alert(item.getValue()); // TEST
IWDatacapture.redraw();
}
The problem is that the event handler function does not fire when the item's value is changed by using the cgi-callout! Any ideas?
Find more posts tagged with
Comments
Migrateduser
I don't see anything wrong in your code, except a nit: to make something readonly, pass "true" to setReadOnly(), not "false".
What happens if you don't make hte instance readonly? Ie, comment out your call to setReadOnly and test. Does it work now? If so, file a support call on this, since it would seem to be a bug.
bw
Bob Walden [bob.walden@interwoven.com]
Interwoven Education Group
IM: Yahoo, MSN bob_walden
Migrateduser
Well, if I don't make the instance readonly; the the change made by the cgi-callout is immediately reflected to the text box. When it was readonly, I had to redraw the data captue form. This actually is not something I want because I want to disable manual entry to this field.
However, this still is no good because the change initiated by the cgi-callout DOES NOT fire the onItemChagne event handler! My publishDateChange function does not execute whether the instance is readonly or not...
Burcin
hitc
I have the same problem,the prob is the onItemChange event is launched only when the field have the focus an loose it.It means that you must click on the field then click elsewhere to launch the event.The solution I use(not really a solution but a obligation),eveberybody can change the value of the field and a the end of your callout script when you put the value into the field,you must do a field_from_the_dct.focus(); after you put the value in the field, otherwise the template do not the detect a change in the field and will not save the value....
This is a teamsite bug....
dennispluken
this is exactly the answer I have been looking for as well... but I still can't get this to work. Could you please expand a little on the details of how to implement this solution. I am sure it is obvious, but I somehow I missing it.
Thanks!
Dennis
If it ain't broke, don't fix it.
If it don't work good, make it better.
hitc
here is a simple example...once the user choose the value,the window close and it put the focus on the dcr field...
#!/iwenv/iw-home/iw-perl/bin/iwperl
use TeamSite::CGI_lite;
use TeamSite::Config;
$|=1;
my $cgi = TeamSite::CGI_lite->new();
$cgi->parse_data();
my $form_name = $cgi->{'form'}{'iw_form_name'};
my $element_name = $cgi->{'form'}{'iw_callback_var'};
my $user_name = $cgi->{'form'}{'user_name'};
my $item_name = $cgi->{'form'}{'iw_item_name'};
my $item_description = $cgi->{'form'}{'iw_item_description'};
my $dcr_name = $cgi->{'form'}{'iw_object_name'};
my $area_path = $cgi->{'form'}{'area_path'};
my $type = $cgi->{'form'}{'type'};
my $param = $ENV{'PATH_INFO'};
print<<"END";
<HTML>
<HEAD>
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function set_datacapture_item_value( selectedValue )
{
if ((window.opener == null) ||
(window.opener.closed))
{
return false;
}
var calloutForm = eval($form_name);
if (!calloutForm)
{
return false;
}
var calloutElementFound = false;
for ( i = 0 ; i < calloutForm.elements.length ; i++ )
{
if (calloutForm.elements
.name == '$element_name')
{
calloutForm.elements
.value = selectedValue;
calloutForm.elements
.focus();
calloutElementFound = true;
break;
}
}
if (!calloutElementFound)
{
return false;
}
return true;
}
function handle_selection()
{
if (callback())
{
if(opener.top.datacapture) {
opener.top.datacapture.refreshForm();
}
self.close();
}
else
{
alert('Please make a selection.');
}
}
function callback()
{
var optionsArray = document.callout_form.selectbox.options;
for ( i = 0 ; i < optionsArray.length ; i++ )
{
if (optionsArray
.selected)
{
if (!set_datacapture_item_value( optionsArray
.value ))
{
alert('Fatal callout error.');
}
return true;
}
}
return false;
}
-->
</script>
</HEAD>
<BODY BGCOLOR="#C0C0C0">
<form name="callout_form">
<TABLE BORDER=0 cellpadding=2 cellspacing=2 WIDTH=80% align="middle">
<tr><TD ALIGN="Center" colspan="2"><B>Selection example of $param </B></td></tr>
<TR>
<td align="middle">
<select name="selectbox">
<option value="Val1_sel">Choose me</option>
<option value="Val2_sel">Pick me Plz</option>
</select>
</td>
<td align="left">
<input type="button" value="push" onclick="handle_selection();">
</td>
</TR>
</TABLE>
</form>
</body>
END
dennispluken
Thanks for the response, I was actually able to figure it out. This script didnt work for me as is but I made the following changes and it worked just fine...
var calloutElementFound = false;
for ( i = 0 ; i < calloutForm.elements.length ; i++ ) {
if (calloutForm.elements
.name == '$element_name') {
calloutForm.elements
.value = selectedValue;
calloutForm.elements
.focus();
i = i + 2;
calloutForm.elements
.focus();
calloutElementFound = true;
break;
}
}
if (!calloutElementFound) {
return false;
}
return true;
}
after I set the value, I established the focus on the current element. Then I changed the focus to the next element (actually the 2nd next element to have it be an input element) which was enough to trigger the onitemChange event handler.
Thanks for your help I was really banging my head against it on this.
dennis
If it ain't broke, don't fix it.
If it don't work good, make it better.