https://wiki.eprints.org/w/index.php?title=API:EPrints/Plugin/InputForm/Component&feed=atom&action=historyAPI:EPrints/Plugin/InputForm/Component - Revision history2024-03-29T14:01:23ZRevision history for this page on the wikiMediaWiki 1.31.8https://wiki.eprints.org/w/index.php?title=API:EPrints/Plugin/InputForm/Component&diff=10829&oldid=prevTdb01r at 12:45, 29 July 20132013-07-29T12:45:23Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 12:45, 29 July 2013</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l22" >Line 22:</td>
<td colspan="2" class="diff-lineno">Line 22:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>In this instance the [[API:EPrints/Plugin/InputForm/Component/Upload|EPrints::Plugin::InputForm::Component::Upload]] component is being inserted into the workflow and its help is being set to always be shown.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>In this instance the [[API:EPrints/Plugin/InputForm/Component/Upload|EPrints::Plugin::InputForm::Component::Upload]] component is being inserted into the workflow and its help is being set to always be shown.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Components share many of the features seen in [[API:EPrints/Plugin/Screen|EPrints::Plugin::Screen]]s. The [[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]] method is called from the Screen's [[API:EPrints/Plugin/InputForm/Component#from|from]] stage and the component [[API:EPrints/Plugin/InputForm/Component#render|render]]s a fragment of XHTML that is inserted into the resulting page. Components have no equivalent to <del class="diffchange diffchange-inline"><code></del>EPrints::Plugin::Screen/can_be_viewed<del class="diffchange diffchange-inline"></code> </del>- it is assumed that the workflow only exposes inputs to which the user has access.</div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Components share many of the features seen in [[API:EPrints/Plugin/Screen|EPrints::Plugin::Screen]]s. The [[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]] method is called from the Screen's [[API:EPrints/Plugin/InputForm/Component#from|from]] stage and the component [[API:EPrints/Plugin/InputForm/Component#render|render]]s a fragment of XHTML that is inserted into the resulting page. Components have no equivalent to <ins class="diffchange diffchange-inline">[[API:EPrints/Plugin/Screen#can_be_viewed|</ins>EPrints::Plugin::Screen/can_be_viewed<ins class="diffchange diffchange-inline">]] </ins>- it is assumed that the workflow only exposes inputs to which the user has access.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>A component will be created twice during a workflow response: to process the incoming data ([[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]]) and to generate the new page ([[API:EPrints/Plugin/InputForm/Component#render|render]]). Therefore you can not rely on data persisting between the update and rendering stages, unless you store the data in the [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>A component will be created twice during a workflow response: to process the incoming data ([[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]]) and to generate the new page ([[API:EPrints/Plugin/InputForm/Component#render|render]]). Therefore you can not rely on data persisting between the update and rendering stages, unless you store the data in the [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].</div></td></tr>
</table>Tdb01rhttps://wiki.eprints.org/w/index.php?title=API:EPrints/Plugin/InputForm/Component&diff=10828&oldid=prevTdb01r at 12:45, 29 July 20132013-07-29T12:45:07Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 12:45, 29 July 2013</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l22" >Line 22:</td>
<td colspan="2" class="diff-lineno">Line 22:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>In this instance the [[API:EPrints/Plugin/InputForm/Component/Upload|EPrints::Plugin::InputForm::Component::Upload]] component is being inserted into the workflow and its help is being set to always be shown.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>In this instance the [[API:EPrints/Plugin/InputForm/Component/Upload|EPrints::Plugin::InputForm::Component::Upload]] component is being inserted into the workflow and its help is being set to always be shown.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Components share many of the features seen in [[API:EPrints/Plugin/Screen|EPrints::Plugin::Screen]]s. The [[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]] method is called from the Screen's [[API:EPrints/Plugin/InputForm/Component#from|from]] stage and the component <del class="diffchange diffchange-inline">renders </del>a fragment of XHTML that is inserted into the resulting page. Components have no equivalent to <code>can_be_viewed<del class="diffchange diffchange-inline">()</del></code> - it is assumed that the workflow only exposes inputs to which the user has access.</div></td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Components share many of the features seen in [[API:EPrints/Plugin/Screen|EPrints::Plugin::Screen]]s. The [[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]] method is called from the Screen's [[API:EPrints/Plugin/InputForm/Component#from|from]] stage and the component <ins class="diffchange diffchange-inline">[[API:EPrints/Plugin/InputForm/Component#render|render]]s </ins>a fragment of XHTML that is inserted into the resulting page. Components have no equivalent to <code><ins class="diffchange diffchange-inline">EPrints::Plugin::Screen/</ins>can_be_viewed</code> - it is assumed that the workflow only exposes inputs to which the user has access.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>A component will be created twice during a workflow response: to process the incoming data ([[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]]) and to generate the new page ([[API:EPrints/Plugin/InputForm/Component#render|render]]). Therefore you can not rely on data persisting between the update and rendering stages, unless you store the data in the [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>A component will be created twice during a workflow response: to process the incoming data ([[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]]) and to generate the new page ([[API:EPrints/Plugin/InputForm/Component#render|render]]). Therefore you can not rely on data persisting between the update and rendering stages, unless you store the data in the [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].</div></td></tr>
</table>Tdb01rhttps://wiki.eprints.org/w/index.php?title=API:EPrints/Plugin/InputForm/Component&diff=10827&oldid=prevTdb01r: Created page with '<!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' com…'2013-07-29T12:42:54Z<p>Created page with '<!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' com…'</p>
<p><b>New page</b></p><div><!-- Pod2Wiki=_preamble_ <br />
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.<br />
-->{{API}}{{Pod2Wiki}}{{API:Source|file=perl_lib/EPrints/Plugin/InputForm/Component.pm|package_name=EPrints::Plugin::InputForm::Component}}[[Category:API|COMPONENT]][[Category:API:EPrints/Plugin/InputForm|COMPONENT]][[Category:API:EPrints/Plugin/InputForm/Component|COMPONENT]]<div><!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name --><br />
==NAME==<br />
'''EPrints::Plugin::InputForm::Component''' - A single form component <br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_description --><br />
==DESCRIPTION==<br />
A component is an HTML widget for use in a [[API:EPrints/Workflow/Stage|EPrints::Workflow::Stage]]. A [[API:EPrints/Plugin/InputForm/Component/Field|EPrints::Plugin::InputForm::Component::Field]] component renders the form inputs for a [[API:EPrints/MetaField|EPrints::MetaField]] but component subclasses can be used to provide any required behaviour around user input. Components don't even have to be form inputs e.g. just render a fragment of XHTML.<br />
<br />
Where components are shown and configuration are controlled through the EPrints XML workflow. The workflow reads the component type, loads the referenced plugin and passes the XML node to [[API:EPrints/Plugin/InputForm/Component#parse_config|parse_config]]:<br />
<br />
<source lang="xml"><component type="Upload" show_help="always" /></source><br />
<br />
In this instance the [[API:EPrints/Plugin/InputForm/Component/Upload|EPrints::Plugin::InputForm::Component::Upload]] component is being inserted into the workflow and its help is being set to always be shown.<br />
<br />
Components share many of the features seen in [[API:EPrints/Plugin/Screen|EPrints::Plugin::Screen]]s. The [[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]] method is called from the Screen's [[API:EPrints/Plugin/InputForm/Component#from|from]] stage and the component renders a fragment of XHTML that is inserted into the resulting page. Components have no equivalent to <code>can_be_viewed()</code> - it is assumed that the workflow only exposes inputs to which the user has access.<br />
<br />
A component will be created twice during a workflow response: to process the incoming data ([[API:EPrints/Plugin/InputForm/Component#update_from_form|update_from_form]]) and to generate the new page ([[API:EPrints/Plugin/InputForm/Component#render|render]]). Therefore you can not rely on data persisting between the update and rendering stages, unless you store the data in the [[API:EPrints/ScreenProcessor|EPrints::ScreenProcessor]].<br />
<br />
Buttons in components are classed as "internal actions". Internal actions do not normally change the response workflow but only how the component renders. This is used to provide search features, provide more button inputs etc.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_ajax_support --><br />
===AJAX Support===<br />
Some components support AJAX-like incremental updates. The Javascript Component class can make requests aimed at a Component by specifying the <code>component=cXX</code> CGI parameter and it is then up to the component what it renders.<br />
<br />
The default behaviour is to render the XHTML fragment represented by the component, which is used by Javascript as an in-place replament. Elsewhere a JSON response is used to drive client-side behaviour.<br />
<br />
Similarly to [[API:EPrints/Plugin/Screen|EPrints::Plugin::Screen]], AJAX components have a life-cycle of:<br />
<br />
* 1. update_from_form() reads form values and sets them on the object<br />
* 2. wishes_to_export() determines if this component is exporting<br />
* 3. export() generates a response<br />
See also [[API:EPrints/Plugin/InputForm/Component/Documents|EPrints::Plugin::InputForm::Component::Documents]], which uses a JSON response to determine the documents to update.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_methods --><br />
==METHODS==<br />
<!-- Pod2Wiki=head_new --><br />
===new===<br />
<br />
<source lang="perl">$component = EPrints::Plugin::InputForm::Component->new( %opts )<br />
<br />
</source><br />
Create a new component object with following parameters:<br />
<br />
<pre> session - session object<br />
collapse - whether the component starts collapsed<br />
no_help - hide field help<br />
no_toggle - hide help toggle button<br />
surround - surround class, defaults to 'Default'<br />
prefix - prefix for the component id<br />
dataobj - object the field is being rendered for</pre><br />
<br />
See also [[API:EPrints/Plugin/InputForm/Surround/Default|EPrints::Plugin::InputForm::Surround::Default]].<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_parse_config --><br />
===parse_config===<br />
<br />
<source lang="perl">$bool = $component->parse_config( $config_dom )<br />
<br />
</source><br />
Parses the supplied DOM object and populates $component configuration.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_is_required --><br />
===is_required===<br />
<br />
<source lang="perl">$bool = $component->is_required()<br />
<br />
</source><br />
returns true if this component is required to be completed before the workflow may proceed<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_get_surround --><br />
===get_surround===<br />
<br />
<source lang="perl">$surround = $component->get_surround()<br />
<br />
</source><br />
returns the surround for this component.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_is_collapsed --><br />
===is_collapsed===<br />
<br />
<source lang="perl">$bool = $component->is_collapsed()<br />
<br />
</source><br />
returns true if this component is to be rendered in a compact form (for example, just title / required / help).<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_render_help --><br />
===render_help===<br />
<br />
<source lang="perl">$help = $component->render_help( $surround )<br />
<br />
</source><br />
Returns DOM containing the help text for this component.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_get_name --><br />
===get_name===<br />
<br />
<source lang="perl">$name = $component->get_name()<br />
<br />
</source><br />
Returns the unique name of this field (for prefixes, etc).<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_wishes_to_export --><br />
===wishes_to_export===<br />
<br />
<source lang="perl">$bool = $component->wishes_to_export<br />
<br />
</source><br />
See [[API:EPrints/Plugin/Screen#wishes_to_export|EPrints::Plugin::Screen/wishes_to_export]].<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_export_mimetype --><br />
===export_mimetype===<br />
<br />
<source lang="perl">$mime_type = $component->export_mimetype<br />
<br />
</source><br />
See [[API:EPrints/Plugin/Screen#export_mimetype|EPrints::Plugin::Screen/export_mimetype]].<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_export --><br />
===export===<br />
<br />
<source lang="perl">$component->export<br />
<br />
</source><br />
See [[API:EPrints/Plugin/Screen#export|EPrints::Plugin::Screen/export]].<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_render --><br />
===render===<br />
<br />
<source lang="perl">$xhtml = $component->render<br />
<br />
</source><br />
Renders the component in its surround.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_render_title --><br />
===render_title===<br />
<br />
<source lang="perl">$title = $component->render_title( $surround )<br />
<br />
</source><br />
Returns the title of this component as a DOM object.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_render_content --><br />
===render_content===<br />
<br />
<source lang="perl">$content = $component->render_content( $surround )<br />
<br />
</source><br />
Returns the DOM for the content of this component.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_has_help --><br />
===has_help===<br />
<br />
<source lang="perl">$boolean = $component->has_help()<br />
<br />
</source><br />
Returns true if this component has help available.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_get_fields_handled --><br />
===get_fields_handled===<br />
<br />
<source lang="perl">@field_ids = $component->get_fields_handled<br />
<br />
</source><br />
Returns an array of the names of the metadata fields which this field handles. Used for jumps.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=head_copyright --><br />
==COPYRIGHT==<br />
Copyright 2000-2013 University of Southampton.<br />
<br />
This file is part of EPrints http://www.eprints.org/.<br />
<br />
EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br />
<br />
EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.<br />
<br />
You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.<br />
<br />
<!-- Edit below this comment --><br />
<br />
<br />
<!-- Pod2Wiki= --><br />
<!-- Pod2Wiki=_postamble_ --><br />
<!-- Edit below this comment --></div>Tdb01r