On 8/23/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi all:
> 
> I have been struggling all day to understand the features provided by
> Shale. Here's what i have so far:
> 
> I have a new skeletal project with just the jars in usecases.war in my
> WEB-INF/lib and 2 trivial jsps. index.jsp which forwards to logon.faces.
> logon.jsp is a usual logon page with un/pw stuff.
> 
> I have a LogonAction class (using org.apache.shale.usecases.profile
> .LogonActions) which extends AbstractViewController. From the API docs for
> ViewController:
> 
> "having your backing beans implement this interface (typically by
> extending AbstractViewController) will receive the benefit of the extra
> services described by this interface, all of which will be provided
> automatically."
> 

I can see that "automatically" needs to be qualified by explaining
what "registered" means below.

> So I took that to mean that Shale has provided me with this nice
> AbstractViewController so all I gotta do is exend it...? So, in my
> LogonAction I implemented init(), prerender() and preprocess() methods
> with trivial code. However, none of these methods are ever getting called.
> (The LogonAction.logon method however *is* getting called...)
> 
> There's more stuff in the docs about:
> To be useful, the ViewController must be plugged into the application
> lifecycle through a custom JSF ViewHandler, like the ShaleViewHandler"
> 
> So am I supposed to plug the LogonAction to ShaleViewHandler? How do I do
> that? (I didn't understand the docs here - and I can explain why but this
> is already a very long message so will desist..)
> 
> Plus there's stuff about "registering" my ViewController bean. But I had
> rather hoped that extending AbstractViewController would mean I wouldn't
> have to do that explicitly..?

You will want to register your view controller beans as a managed bean
anyway, so that JSF will create them for you on demand.  But, for
Shale to provide the services it does, it must know how to translate
the "view id" --- something like "/logon.jsp" -- into the name of the
corresponding managed bean.  That way, when you navigate to that page,
Shale can precreate the bean and call the relevant event handlers.

There is an API defining a mapper (ViewControllerMapper), and a
default implementation (DefaultViewControllerMapper) that applies the
following rules to transform a viewId into a managed bean name:
* Strip any leading slash ("/") character
* Strip any trailing extension (such as ".jsp")
* Convert any remaining instance of a slash ("/") into a dollar sign ("$")

Thus, the managed bean name corresponding to "/logon.jsp" *must* be
named "logon" for it to be recognized as a ViewController.  In your
scenario, you left the name copied from the Use Cases example
("logon$profile"), which would be suitable for a page named
"/logon/profile.jsp".
> 
> I have looked at the logon stuff in faces-confing.xml in usecases.war but
> am afraid have drawn a blank..Kinda stuck at this point..(:(
> 
> Can someone please help me see what i am missing? Many thanks in advance!
> Geeta
> 
> p.s. my faces-config.xml looks like this:
> 
> <managed-bean>
>     <managed-bean-name>profile$logon</managed-bean-name>

Change this to "logon" and update any value binding expressions that
use it as well.

>     <managed-bean-class>
>       com.intellicare.shaleNShark.logon.LogonAction
>     </managed-bean-class>
>     <managed-bean-scope>request</managed-bean-scope>
>     <managed-property>
>       <description>
>         Session scope attribute key under which the User instance for a
>         logged on user is stored.
>       </description>
>       <display-name>User Key</display-name>
>       <property-name>userKey</property-name>
>       <property-class>java.lang.String</property-class>
>       <value>user</value>
>     </managed-property>
>   </managed-bean>
> 
>  <navigation-rule>
>     <from-view-id>*</from-view-id>
>     <navigation-case>
>       <from-outcome>authenticated</from-outcome>
>       <to-view-id>/success.jsp</to-view-id>
>     </navigation-case>
>     <navigation-case>
>       <from-outcome>unauthenticated</from-outcome>
>       <to-view-id>/failure.jsp</to-view-id>
>     </navigation-case>
>   </navigation-rule>
> 
> 

And yes, the javadocs do need to be clearer about the need for this. 
I'll add some more information to the ViewController class docs to
explain it.

Craig

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

Reply via email to