I placed a copy of Login.java under screen/ directory. I assume that
this Login.class file will be executed prior to the Login.vm file. Here
is my Login.java file:
public class Login extends VelocityScreen
{
public void doBuildTemplate(RunData data, Context context)
{
context.put("nextTemplate",
data.getScreenTemplate().replace('/',',')); try {
isAuthorized(data); }
catch (Exception e)
{ }
}
protected boolean isAuthorized( RunData data ) throws Exception
{
boolean isAuthorized = false;
AccessControlList acl = data.getACL();
if (acl==null || ! acl.hasRole("turbine_root"))
{ this.doRedirect(data, "Login.vm");
isAuthorized = false;
} else if(acl.hasRole("turbine_root")) {
isAuthorized = true;
}
return isAuthorized;
}
}
In my Login.vm file, I have this line to read the info:
<form method="post"
action="$link.setAction("Login").setPage("$nextTemplate")">
but $nextTemplate did not get passed... where did I do wrong?
michael
> On Tue, 7 Jan 2003 15:42, you wrote:
>> I am asking a slightly different question (which has been asked
>> before).
>>
>> I want to direct a user to a page that is passed on to him, via an
>> email, say.
>>
>> http://somewhere.com/somecomp/servlet/somecomp/SOME.vm,id?1
>
> I don't really understand what you are asking, but I think you are
> saying that you want to email a link to a secure page to someone who
> must log in before viewing the page.
>
>> I would imagine that this link is passed on as a parameter and read
>> by a .class file, then passon to Velocity via
>> context.put("somelink", "the_above_link"); then, read by the Login.vm
>> file using:
>>
>> <form method="post"
>> action="$link.setAction("Login").setPage($the_above_link)">
>>
>> 1. I don't know which .java file I should use to read the link.
>
> For security you can either write your own session validator class or
> do your security checks in your screen class in the isAuthorized()
> method (the screen class in your example above would either be
> SOME.java or Default.java) and redirect the user to your login
> template.
>
>> 2. in the file that reads this link, what should be put in place of
>> the XXXX
>>
>> String link = data.getParameters().getString("XXXX");
>
> Assuming you are doing your security checks in your screen class, try
> the following code...
>
> context.put("nextTemplate",
> data.getScreenTemplate().replace('/',','));
>
> ... you can then access this from your login template as
> $nextTemplate.
>
> Note, you will also need to pass any request parameters across to the
> screen you are redirecting to.
>
>> 3. setAction("Login").setPage($YYY) in the Form field does not seem
>> to work, $YYY is not accepted, a String (i.e. Somefile.vm) is OK.
>
> Try setAction("Login").setPage("$YYY") instead.
>
> Regards,
>
> -- Rodney
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>