You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Johannes Becker <jo...@gmx.net> on 2005/05/12 15:13:34 UTC
flow question - Is there some function like System.out.println("xxx");
Hi,
I wondered if there is some function like System.out.println("xxx"); for
flow.
thanks
jonny
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Login and CForms - How to handle in FlowScript?
Posted by Johannes Becker <jo...@gmx.net>.
This helped a lot and saved the day. Thanks a lot for your help.
Jonny
Mark Lundquist wrote:
> Hi Jonny,
>
> On Jun 14, 2005, at 3:45 AM, Johannes Becker wrote:
>
>> Hi,
>>
>> I have a CForm (Definiton + Template) and a login-function in flow.
>> Now I want to combine these two.
>>
>> function loginpage() {
>> var loginForm = new Form("forms/LoginForm_d.xml");
>> loginForm.showForm("form/LoginForm");
>> }
>>
>> function login() {
>> var message = false;
>> var username = cocoon.request.get("username");
>> var password = cocoon.request.get("password");
>>
>> account = getStore().readAccount(username, password);;
>> if (account == null) {
>> return message;
>> } else {
>> message = "true";
>> return message; }
>> }
>> }
>>
>> Is it possible (and wise) to change the loginpage()-function like this:
>>
>> function loginpage() {
>> while(true){
>> var loginForm = new Form("forms/LoginForm_d.xml");
>> loginForm.showForm("form/LoginForm");
>> var loggedin = login();
>> if(loggedin == "true") break;
>> }
>>
>> Since this approach doesn't seem quite right and efficient to me:
>
>
> Yeah, you're right... it's not quite right :-)
>
> First some random observations:
>
> - You don't have to call the Form() constructor every time through
> your loop. You only build the form model once, and you can display it
> and accept submissions many times with the same Form object.
>
> - The style in CForms is to let the framework deal with the form
> parameters... you get the data by interrogating the widgets. So lose
> the calls to cocoon.request.get(), and ask the widgets for their
> values instead (see example below). Also, I think it's bad form
> (pardon the pun) to be displaying a form in one bit of flowscript, and
> handling the parameters from the form submission in another piece of
> flowscript. Part of the reason flowscript exists is so that you don't
> have to do like in the "page scripting" mentality :-)
>
> - returning a string "true" is surely not the best? Booleans work
> just fine in flowscript :-).
>
> - How does your application know to call loginpage()? You need to
> keep track of whether the session user is logged in, and I don't see
> that anywhere in your code...
>
> - You probably want to display some kind of message on an unsuccessful
> login attempt?
>
>
> I've done "authentication 'lite'", i.e. using flowscript only, w/o the
> auth-fw, and you can do it more or less something like this:
>
> Suppose you have a flowscript function like this, that does something
> you want protected by the login mechanism:
>
> function showStuff() {
> getLoggedInUser(); // make sure the user is logged
> in...
>
> .
> . // whatever
> .
> }
>
> getLoggedInUser() is a function that doesn't return until the user has
> successfully authenticated. So now we need:
>
> var currentUser = null; // note, global
> flowscript variables are attached to the session
>
> function getLoggedInUser() {
> if (currentUser == null) {
> currentUser = login();
> }
> }
>
>
> function login() {
> var loginForm = new Form("forms/LoginForm_d.xml");
> var model = loginForm.getModel();
> var loginUser = null;
> var invalidLogin = false;
>
> while (loginUser == null) {
> loginForm.showForm(
> "form/LoginForm",
> {
> invalidLogin: invalidLogin
> }
> );
> loginUser = getStore().readAccount (model.username,
> model.password);
> invalidLogin = true;
> }
> return loginUser;
> }
>
> In your LoginForm template, use the JXTemplate language to
> conditionally display an error message based on the invalidLogin
> variable passed in from flowscript... something like
>
> <jx:if test="${invalidLogin == 'true'}">
> <p class="error">
> Incorrect login ID and/or password.
> </p>
> </jx:if>
>
> I think that's about all there is to it. Note, the above code sample
> is written for the 'v1' flowscript forms API because that's what you
> should probably be using. I've been using the 'v2' API for a long
> time so my 'v1' is a little rusty... somebody else might be able to
> improve the code in my example or correct it if need be :-)
>
> HTH,
> —ml—
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Login and CForms - How to handle in FlowScript?
Posted by Mark Lundquist <ml...@wrinkledog.com>.
Hi Jonny,
On Jun 14, 2005, at 3:45 AM, Johannes Becker wrote:
> Hi,
>
> I have a CForm (Definiton + Template) and a login-function in flow.
> Now I want to combine these two.
>
> function loginpage() {
> var loginForm = new Form("forms/LoginForm_d.xml");
> loginForm.showForm("form/LoginForm");
> }
>
> function login() {
> var message = false;
> var username = cocoon.request.get("username");
> var password = cocoon.request.get("password");
>
> account = getStore().readAccount(username, password);;
> if (account == null) {
> return message;
> } else {
> message = "true";
> return message; }
> }
> }
>
> Is it possible (and wise) to change the loginpage()-function like this:
>
> function loginpage() {
> while(true){
> var loginForm = new Form("forms/LoginForm_d.xml");
> loginForm.showForm("form/LoginForm");
> var loggedin = login();
> if(loggedin == "true") break;
> }
>
> Since this approach doesn't seem quite right and efficient to me:
Yeah, you're right... it's not quite right :-)
First some random observations:
- You don't have to call the Form() constructor every time through your
loop. You only build the form model once, and you can display it and
accept submissions many times with the same Form object.
- The style in CForms is to let the framework deal with the form
parameters... you get the data by interrogating the widgets. So lose
the calls to cocoon.request.get(), and ask the widgets for their values
instead (see example below). Also, I think it's bad form (pardon the
pun) to be displaying a form in one bit of flowscript, and handling the
parameters from the form submission in another piece of flowscript.
Part of the reason flowscript exists is so that you don't have to do
like in the "page scripting" mentality :-)
- returning a string "true" is surely not the best? Booleans work just
fine in flowscript :-).
- How does your application know to call loginpage()? You need to keep
track of whether the session user is logged in, and I don't see that
anywhere in your code...
- You probably want to display some kind of message on an unsuccessful
login attempt?
I've done "authentication 'lite'", i.e. using flowscript only, w/o the
auth-fw, and you can do it more or less something like this:
Suppose you have a flowscript function like this, that does something
you want protected by the login mechanism:
function showStuff() {
getLoggedInUser(); // make sure the user is logged in...
.
. // whatever
.
}
getLoggedInUser() is a function that doesn't return until the user has
successfully authenticated. So now we need:
var currentUser = null; // note, global flowscript variables are
attached to the session
function getLoggedInUser() {
if (currentUser == null) {
currentUser = login();
}
}
function login() {
var loginForm = new Form("forms/LoginForm_d.xml");
var model = loginForm.getModel();
var loginUser = null;
var invalidLogin = false;
while (loginUser == null) {
loginForm.showForm(
"form/LoginForm",
{
invalidLogin: invalidLogin
}
);
loginUser = getStore().readAccount (model.username, model.password);
invalidLogin = true;
}
return loginUser;
}
In your LoginForm template, use the JXTemplate language to
conditionally display an error message based on the invalidLogin
variable passed in from flowscript... something like
<jx:if test="${invalidLogin == 'true'}">
<p class="error">
Incorrect login ID and/or password.
</p>
</jx:if>
I think that's about all there is to it. Note, the above code sample
is written for the 'v1' flowscript forms API because that's what you
should probably be using. I've been using the 'v2' API for a long time
so my 'v1' is a little rusty... somebody else might be able to improve
the code in my example or correct it if need be :-)
HTH,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Login and CForms - How to handle in FlowScript?
Posted by Johannes Becker <jo...@gmx.net>.
Hi,
I have a CForm (Definiton + Template) and a login-function in flow. Now
I want to combine these two.
function loginpage() {
var loginForm = new Form("forms/LoginForm_d.xml");
loginForm.showForm("form/LoginForm");
}
function login() {
var message = false;
var username = cocoon.request.get("username");
var password = cocoon.request.get("password");
account = getStore().readAccount(username, password);;
if (account == null) {
return message;
} else {
message = "true";
return message;
}
}
}
Is it possible (and wise) to change the loginpage()-function like this:
function loginpage() {
while(true){
var loginForm = new Form("forms/LoginForm_d.xml");
loginForm.showForm("form/LoginForm");
var loggedin = login();
if(loggedin == "true") break;
}
Since this approach doesn't seem quite right and efficient to me:
- Is there a better approach? (I guess there is)
- Any suggestions how I can solve this problem?
Thanks
Jonny
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like
System.out.println("xxx");
Posted by "Arsen A. Gutsal" <ar...@softsky.com.ua>.
Packages.java.lang.System.out.println("xxx");
On Thu, 2005-05-12 at 15:13 +0200, Johannes Becker wrote:
> Hi,
>
> I wondered if there is some function like System.out.println("xxx"); for
> flow.
>
> thanks
> jonny
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Sincerely,
Arsen A. Gutsal
SOFTSKY Ltd CEO/Executive
SOFTSKY - Cost effective Software Development
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like System.out.println("xxx");
Posted by Roberto Marra <rm...@montefiore.ch>.
yes
System.out.println("xxx");
or
java.lang.System.out.println("xxx");
if you don't want to everytime write the entire package just add at top of
the file:
importPackage(java.lang);
Cheers
Roberto
----- Original Message -----
From: "Johannes Becker" <jo...@gmx.net>
To: "Cocoon" <us...@cocoon.apache.org>
Sent: Thursday, May 12, 2005 3:13 PM
Subject: flow question - Is there some function like
System.out.println("xxx");
> Hi,
>
> I wondered if there is some function like System.out.println("xxx"); for
> flow.
>
> thanks
> jonny
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like
System.out.println("xxx");
Posted by "Arsen A. Gutsal" <ar...@softsky.com.ua>.
no difference
On Thu, 2005-05-12 at 16:07 +0200, Johannes Becker wrote:
> Hi,
>
> thanks Roberto and all the others who helped me.
> java.lang.System.out.println("xxx"); worked for me.
>
> I didn' know there was a difference between "Packages.java.xxx" and
> "java.xxx".
>
> Cheers
> Jonny
>
>
> Roberto Marra wrote:
>
> Try:
>
> java.lang.System.out.println("xxx");
>
> & you will see that it works, trust me...
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Sincerely,
Arsen A. Gutsal
SOFTSKY Ltd CEO/Executive
SOFTSKY - Cost effective Software Development
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like System.out.println("xxx");
Posted by Johannes Becker <jo...@gmx.net>.
Hi,
thanks Roberto and all the others who helped me.
java.lang.System.out.println("xxx"); worked for me.
I didn' know there was a difference between "Packages.java.xxx" and
"java.xxx".
Cheers
Jonny
Roberto Marra wrote:
Try:
java.lang.System.out.println("xxx");
& you will see that it works, trust me...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like System.out.println("xxx");
Posted by Roberto Marra <rm...@montefiore.ch>.
Try:
java.lang.System.out.println("xxx");
& you will see that it works, trust me...
----- Original Message -----
From: "Johannes Becker" <jo...@gmx.net>
To: <us...@cocoon.apache.org>
Sent: Thursday, May 12, 2005 3:51 PM
Subject: Re: flow question - Is there some function like
System.out.println("xxx");
> Hi,
>
> somehow print("xxx"); and Packages.java.lang.System.out.println("xxx");
> don't work for me.
>
> function seeSomeStringInCommandWindow() {
> // either
> print("Hello");
> // or
> Packages.java.lang.System.out.println("xxx");
> // let me see some output in the CommandWindow
> cocoon.sendPage("blabla");
> }
>
> Or did I understand you wrong what "they" do?
>
> Thanks
> Jonny
>
>
>
>
> Mark Leicester wrote:
>
> > Hi Jonny,
> >
> > print("xxx") works for me.
> >
> > Cheers,
> > Mark
> >
> > On 12 May 2005, at 14:13, Johannes Becker wrote:
> >
> >> Hi,
> >>
> >> I wondered if there is some function like System.out.println("xxx");
> >> for flow.
> >>
> >> thanks
> >> jonny
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like System.out.println("xxx");
Posted by Johannes Becker <jo...@gmx.net>.
Hi,
somehow print("xxx"); and Packages.java.lang.System.out.println("xxx");
don't work for me.
function seeSomeStringInCommandWindow() {
// either
print("Hello");
// or
Packages.java.lang.System.out.println("xxx");
// let me see some output in the CommandWindow
cocoon.sendPage("blabla");
}
Or did I understand you wrong what "they" do?
Thanks
Jonny
Mark Leicester wrote:
> Hi Jonny,
>
> print("xxx") works for me.
>
> Cheers,
> Mark
>
> On 12 May 2005, at 14:13, Johannes Becker wrote:
>
>> Hi,
>>
>> I wondered if there is some function like System.out.println("xxx");
>> for flow.
>>
>> thanks
>> jonny
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like System.out.println("xxx");
Posted by Mark Leicester <ma...@efurbishment.com>.
Hi Jonny,
print("xxx") works for me.
Cheers,
Mark
On 12 May 2005, at 14:13, Johannes Becker wrote:
> Hi,
>
> I wondered if there is some function like System.out.println("xxx");
> for flow.
>
> thanks
> jonny
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: flow question - Is there some function like System.out.println("xxx");
Posted by "n." <eb...@gmail.com>.
can you not put it in the log?
On 5/12/05, Johannes Becker <jo...@gmx.net> wrote:
> Hi,
>
> I wondered if there is some function like System.out.println("xxx"); for
> flow.
>
> thanks
> jonny
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Want to be a Chess Artist? - groups-beta.google.com/group/ChessCombinations/
Whats it like to dance in London? -
groups-beta.google.com/group/LondonDanceNetwork/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
RE: flow question - Is there some function like System.out.println("xxx");
Posted by trondal <tr...@stud.ntnu.no>.
Hi.
print(varablename);
or
print("some string");
Works much the same like system.out. Can use print(variablename+"string");
also
Regards Trond
-----Original Message-----
From: Johannes Becker [mailto:jonnybecker@gmx.net]
Sent: 12. mai 2005 15:14
To: Cocoon
Subject: flow question - Is there some function like
System.out.println("xxx");
Hi,
I wondered if there is some function like System.out.println("xxx"); for
flow.
thanks
jonny
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org