diff --git a/lib/WebGUI/Form/AssetReportQuery.pm b/lib/WebGUI/Form/AssetReportQuery.pm
index 28c2ee018..fe2703efc 100644
--- a/lib/WebGUI/Form/AssetReportQuery.pm
+++ b/lib/WebGUI/Form/AssetReportQuery.pm
@@ -169,6 +169,20 @@ sub getValue {
#-------------------------------------------------------------------
+=head2 headTags
+
+Sets the JS for this form plugin
+
+=cut
+
+sub headTags {
+ my $self = shift;
+ my $session = $self->session;
+ $session->style->setScript($session->url->extras("yui-webgui/build/form/assetReportQuery.js"),{ type=>"text/javascript" });
+}
+
+#-------------------------------------------------------------------
+
=head2 i18n
Returns the i18n object for the form
@@ -186,6 +200,7 @@ sub i18n {
return $self->{_i18n};
}
+
#----------------------------------------------------------------------------
=head2 toHtml
@@ -246,7 +261,6 @@ sub toHtml {
$style->setRawHeadTags(qq||);
my $jsonData = $self->get("value") || q|{ "isNew" : "true" }|;
$style->setRawHeadTags(qq||);
- $session->style->setScript($session->url->extras("yui-webgui/build/form/assetReportQuery.js"),{ type=>"text/javascript" });
#Decode JSON data for filling in some of the fields
my $jsonDataHash = JSON->new->decode($jsonData);
diff --git a/lib/WebGUI/Form/JsonTable.pm b/lib/WebGUI/Form/JsonTable.pm
index d3cc2812b..8b564900f 100644
--- a/lib/WebGUI/Form/JsonTable.pm
+++ b/lib/WebGUI/Form/JsonTable.pm
@@ -129,6 +129,31 @@ sub getValue {
#-------------------------------------------------------------------
+=head2 headTags ( )
+
+Send JS required for this plugin.
+
+=cut
+
+sub headTags {
+ my $self = shift;
+ my ( $url, $style ) = $self->session->quick(qw( url style ));
+ $style->setScript(
+ $url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'),
+ { type => 'text/javascript' },
+ );
+ $style->setScript(
+ $url->extras('yui/build/json/json-min.js'),
+ { type => 'text/javascript' },
+ );
+ $style->setScript(
+ $url->extras('yui-webgui/build/form/jsontable.js'),
+ { type => 'text/javascript' },
+ );
+}
+
+#-------------------------------------------------------------------
+
=head2 toHtml ( )
Renders an input tag of type text.
@@ -193,21 +218,12 @@ sub toHtml {
$output .= '';
# Existing rows are entirely built in javascript from the JSON in the hidden field
- $style->setScript(
- $url->extras('yui/build/yahoo-dom-event/yahoo-dom-event.js'),
- { type => 'text/javascript' },
- );
- $style->setScript(
- $url->extras('yui/build/json/json-min.js'),
- { type => 'text/javascript' },
- );
- $output .= sprintf '',
- $url->extras('yui-webgui/build/form/jsontable.js');
$output .= '';
+ $self->headTags;
return $output;
}
diff --git a/lib/WebGUI/Form/Text.pm b/lib/WebGUI/Form/Text.pm
index 35d582323..bc7657432 100644
--- a/lib/WebGUI/Form/Text.pm
+++ b/lib/WebGUI/Form/Text.pm
@@ -125,6 +125,7 @@ Renders an input tag of type text.
sub toHtml {
my $self = shift;
+ $self->headTags();
my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
return 'get("extras").' />';
}
diff --git a/lib/WebGUI/Form/Url.pm b/lib/WebGUI/Form/Url.pm
index 528928260..dca3357bd 100644
--- a/lib/WebGUI/Form/Url.pm
+++ b/lib/WebGUI/Form/Url.pm
@@ -125,6 +125,22 @@ sub getValueAsHtml {
}
+#-------------------------------------------------------------------
+
+=head2 headTags ( )
+
+Add JS.
+
+=cut
+
+sub headTags {
+ my $self = shift;
+ return if $self->headTagsSent;
+ $self->session->style->setScript($self->session->url->extras('addHTTP.js'),{ type=>'text/javascript' });
+ $self->SUPER::headTags();
+ return;
+}
+
#-------------------------------------------------------------------
=head2 isDynamicCompatible ( )
@@ -147,7 +163,6 @@ Renders a URL field.
sub toHtml {
my $self = shift;
- $self->session->style->setScript($self->session->url->extras('addHTTP.js'),{ type=>'text/javascript' });
$self->set("extras", $self->get('extras') . ' onblur="addHTTP(this.form.'.$self->get("name").')"');
return $self->SUPER::toHtml;
}