> This is from 
> <jetspeed-home>\WEB-INF\templates\vm\navigations\html\top.vm
> 
> <form method="POST" action="$link"
> enctype="application/x-www-form-urlencoded">
> <input name="$jlink.ActionKey" type="hidden"
> value="$config.getString("action.login")" />
> 
> Q: please explain how to define "action", "enctype", input 
> "name" "value".

Ok, enctype first, since that's easiest.  The enctype (encoding type) field
is standard HTML for how form data is to be encoded by the browser for
submittal to the server -- you define what enctype field by editting the
top.vm file directly, since that's hard-coded.

For the remaining items, you need to understand that Jetspeed uses Turbine
for page layout, and Turbine, in turn, uses the Velocity macro engine.
Thus, to understand Jetspeed, you need to understand the documentation at
http://jakarta.apache.org/turbine/turbine-2/ and
http://jakarta.jetspeed.org/velocity/.  In particular, check out
http://jakarta.apache.org/turbine/turbine-2/howto/velocity-site-howto.html
and http://jakarta.apache.org/turbine/turbine-2/howto/context-howto.html.
You can also download the Turbine Developer Kit (TDK) from
http://jakarta.apache.org/builds/jakarta-turbine/release/2.1/tdk-2.1.zip --
the Turbine developer docs, including javadocs, are in
.../tdk/webapps/site/turbine-docs/.

In a nutshell, Velocity lets you embed macros like $foo in your HTML, and
the Velocity engine will substitute some other value (defined by you, the
developer) at run-time.  You can think of it as an alternative to JSP.
Turbine is a framework for developing web applications, and provides
standard web application functions like handling user logins, adding top and
left-side navigation bars to all web pages, etc.

Now, for the specifics.

...action="$link"...  The "action=" part is standard HTML form stuff, the
$link is a velocity macro that maps to a Turbine object called TemplateLink.
At run-time, "$link" by itself dynamically generates a link back to your
portal home page.  The hidden field immediately after the <form> tag
specifies that when the form is submitted, Jetspeed should execute the
"JLoginUser" action, as follows:

...name="$jlink.ActionKey"... The $jlink.ActionKey bit is another velocity
macro which maps to a JetspeedTemplateLink object, which is an extension of
TemplateLink that knows about portals.  The $jlink.ActionKey syntax means
"call the ActionKey method of the jlink object.  It's the velocity
equivalent of

  return jlink.ActionKey();

which returns the action parameter name, which is simply the string
"action".  This value is hard-coded in
org.apache.jetspeed.util.template.JetspeedTemplateLink.java.  It simply
means "This (hidden) input field is passing you the name of the action I
want to execute."

...value="$config.getString("action.login")"... is another velocity macro
which calls the getString() method of the $config object, passing it
"action.login" as a parameter.  The "action.login" value is defined in the
TurbineResources.properties file.

By the time Turbine and Velocity get done with it, the section of top.vm you
quoted winds up looking like this (at least on my machine):

<form method="POST" action="http://localhost:8080/jetspeed/portal";
enctype="application/x-www-form-urlencoded">
<input name="action" type="hidden" value="JLoginUser" />

> <td class=MENUBUTTON><a
> href="$link.setPage("NewAccount")">$l10n.TOP_CREATENEWACCOUNT</a></td>

The $l10n Velocity object returns the internationalized value of, in this
case, the TOP_CREATENEWACCOUNT resource.  The $l10n object is a bit fancy in
that it checks the current locale setting of the current user, and then
returns the corresponding internationalized resource from
<jetspeed_home>/WEB-INF/classes/org/apache/jetspeed/modules/localization/Jet
speedLocalizationxxx.properties, where xxx is the underscore ("_") followed
by the lowercase 2-letter country code.  Thus, to change the text, open the
appropriate JetspeedLocalizatonxxx.properties file, search for
TOP_CREATENEWACCOUNT, and then modify the text.  Be aware that you need to
modify the default localization file AND the language-specific localization
file for what ever language is the default locale for your location.

> Q: please define "$link.setPage("NewAccount")", where is it link to?

Remember that $link is Turbine's TemplateLink object -- the setPage("Foo")
method creates a link to a template named Foo.vm.  Thus, the above code
creates a link to a NewAccount.vm template, which resides in
<jetspeed-home>/WEB-INF/templates/vm/screens/html/NewAccount.vm.  

> Q: what is the "$l10n." in front of "TOP_CREATENEWACCOUNT", 
> how to access
> other "predefined" variable in other .properties file?

The $l10n object is the Internationalization object, which lets you extract
all the text messages in your portals, and move them to external
localization files, so that you can more easily manage localization.  That
way your web designers can lay out a login page that calls
$l10n.TOP_CREATENEWACCOUNT, and not have to worry about what language that
message will ultimately be displayed in.  Also you can hire translators
without needing them to know HTML, JSP, VM, Turbine, etc.

Hope this helps -- I had no idea how to answer most of your questions when I
started but I thought this would be a good exercise for me getting to know
the app.  I'd be grateful for any corrections or clarifications to anything
I may have messed up.

Mark


This e-mail and any attachments are confidential. If you are not the
intended recipient, please notify us immediately by reply e-mail and then
delete this message from your system. Do not copy this e-mail or any
attachment, use the contents for any purposes, or disclose the contents to
any other person: to do so could be a breach of confidence.

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to