taylor 2004/04/09 10:02:31
Added: tutorial/xdocs/6 initparams.xml
Log:
6.3 converted to xdocs
PR:
Obtained from:
Submitted by:
Reviewed by:
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.1 jakarta-jetspeed/tutorial/xdocs/6/initparams.xml
Index: initparams.xml
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<document>
<properties>
<author email="[EMAIL PROTECTED]">David Sean Taylor</author>
<title>Init Parameters, Attributes and Titles</title>
</properties>
<body>
<section name="Init Parameters, Attributes and Titles">
<p>
The Portlet interface allows for you to set two different types of configuration
variables
for your portlet and its instances. Init Parameters are defined in the registry.
Attributes are defined in a PSML file. Init Parameters are associated with all
portlets
of a given class and are read only. Attributes are associated with only one instance
of
a portlet class on a given PSML page, and can be modified and persisted. Given our
example
portlet, we have the Init Parameter named 'version', which is set to the value
'1.4b4'.
We also have two instances of the same portlet on our page.
Each of these portlets instances have the same parameter defined on the same PSML
page,
called 'city' with the value of 'Tokyo' and 'Sidney'.
</p>
<p>
Here is the Init Parameter defined in the registry.
Init Parameters can be hidden.
This means they will not be displayed in certain areas of the application such as
portlet customization:
</p>
<source>
<![CDATA[
<parameter name="version" value="1.4b4" hidden="false"/>
]]>
</source>
<p>
And the attributes for each portlet instance:
</p>
<source>
<![CDATA[
<entry parent="HelloPortletInterface">
<parameter name='city' value='Tokyo'/>
</entry>
<entry parent="HelloPortletInterface">
<parameter name='city' value='Sidney'/>
</entry>
]]>
</source>
<p>
The portlet interface supports working with portlet instances directly using the
methods:
</p>
<source>
<![CDATA[
getID() : returns the unique Portlet instance id
getInstance() : returns the instance associated with this portlet.
getAttribute() : returns a persistent attribute from page storage
setAttribute() : stores an attribute to a persistent page
]]>
</source>
<p>
For accessing read only Init Parameters, you must first get the
<a
href='http://portals.apache.org/jetspeed-1/apidocs/org/apache/jetspeed/portal/PortletConfig.html'>PortletConfig</a>
object for a portlet, and from there you can get the Init Parameters.
From the getContent method:
</p>
<source>
<![CDATA[
text.append("Portlet id = " + this.getID());
text.append("<BR/>");
text.append("Init Parameter (version): " +
pc.getInitParameter("version", "NOT FOUND!");
text.append("<BR/>");
text.append("Page Attribute (city): "
+ this.getAttribute("city", "NOT FOUND!", rundata);
]]>
</source>
<p>
The Jetspeed Portlet customizer only displays Init Parameters in the edit window.
Thus the 'city' attribute described above will not show up in the customizer,
since it doesn't have an Init Parameter associated with it.
The portlet customizer associates Attributes with Init Parameters,
and allows you to edit the parameter, but when it is saved, it is saved as an
attribute to the current page, and is not saved to the common registry entry.
</p>
<p>
Lets try customizing the first Hello Portlet Interface portlet:
</p>
<img border='0' width='553' height='160' src="../images/image006-4.jpg"/>
<p>
Press update and we see:
</p>
<img border='0' width='344' height='329' src="../images/image006-5.jpg"/>
<p>
If you want to use the default customizer,
it is recommended that all of your parameters be defined in the portlet registry
when you deploy your portlets. Also notice that the title was changed.
Titles are maintained with the Portlet interface methods
<a
href='http://portals.apache.org/jetspeed-1/apidocs/org/apache/jetspeed/portal/Portlet.html#getTitle()'>getTitle</a>
and
<a
href='http://portals.apache.org/jetspeed-1/apidocs/org/apache/jetspeed/portal/Portlet.html#setTitle()'>setTitle</a>.
</p>
</section>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]