Re: Flow and State of a portlet

2003-02-20 Thread Santiago Gala
Jean-Christophe Kermagoret wrote:

Luta, Raphael (VUN) wrote:


De : Jean-Christophe Kermagoret [mailto:[EMAIL PROTECTED]]
 

It's possible to have this kind of behaviour with a javascript 
function that values the "action" and "template" parameter for each 
case. For example :

function SubmitDefault() {
   form.action.value = "MyDefaultPortletAction";
   form.template.value = "MyDefaultTemplate.vm" ;
}

function SubmitToUpdate() {
   form.action.value = "MyUpdatePortletAction";
   form.template.value = "MyUpdateTemplate.vm" ;
}
...
What are the reasons to use several action and template variables ?

  


You probably don't want to do this in JS, for 3 reasons:
- you don't trust your client (and if you do, you should not :)
- you can't guarantee that your client will actually execute the
 code
- you break the MVC pattern by encoding controller information  in 
your template and tying your different templates together

IMO, you should never explicitely set a template from another
one but always abstract your application flow through a "state"
that is mapped to a template view by your controller code.
It also makes it much easier to validate the current state of the
application.

--
Raphaël Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

--
To unsubscribe, e-mail:   

For additional commands, e-mail: 


 

I agree with what you are saying but :
1 - I can bypass security with hidden fields the same way I could bypass 
it with JS

I think Raphael speaked more about those annoying "Script error in page, 
line..." Debug or Cancel? dialog boxes than about security. It is 
amazing how many newbies I have seen staring into the Javascript 
debugger in Windows.

2 - Almost everybody has javascript enabled


This depends largely on your target. With Javascript you can spoil 
completely the possibility (for instance) of Google indexing your page. 
I've seen quite a few such examples. Or have a page where no link works 
with Mozilla or a Nokia phone, for instance.

3 - Using JS is like your hidden fields : designers can change them 
without breaking anything.

I still don't see any differences. Where are my glasses :-)


You are introducing unneeded complexity just where you cannot control 
it. (Occam's razor?)

Go look for them, truly. ;-)

--
Jean-Christophe Kermagoret
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   

For additional commands, e-mail: 




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




Re: Flow and State of a portlet

2003-01-28 Thread Jean-Christophe Kermagoret
Luta, Raphael (VUN) wrote:


De : Jean-Christophe Kermagoret [mailto:[EMAIL PROTECTED]]
 

It's possible to have this kind of behaviour with a 
javascript function 
that values the "action" and "template" parameter for each case. For 
example :

function SubmitDefault() {
   form.action.value = "MyDefaultPortletAction";
   form.template.value = "MyDefaultTemplate.vm" ;
}

function SubmitToUpdate() {
   form.action.value = "MyUpdatePortletAction";
   form.template.value = "MyUpdateTemplate.vm" ;
}
...
What are the reasons to use several action and template variables ?

   


You probably don't want to do this in JS, for 3 reasons:
- you don't trust your client (and if you do, you should not :)
- you can't guarantee that your client will actually execute the
 code
- you break the MVC pattern by encoding controller information 
 in your template and tying your different templates together

IMO, you should never explicitely set a template from another
one but always abstract your application flow through a "state"
that is mapped to a template view by your controller code.
It also makes it much easier to validate the current state of the
application.

--
Raphaël Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 

 

I agree with what you are saying but :
1 - I can bypass security with hidden fields the same way I could bypass 
it with JS
2 - Almost everybody has javascript enabled
3 - Using JS is like your hidden fields : designers can change them 
without breaking anything.

I still don't see any differences. Where are my glasses :-)

--
Jean-Christophe Kermagoret
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 



RE: Flow and State of a portlet

2003-01-28 Thread Luta, Raphael (VUN)
De : Jean-Christophe Kermagoret [mailto:[EMAIL PROTECTED]]
> 
> It's possible to have this kind of behaviour with a 
> javascript function 
> that values the "action" and "template" parameter for each case. For 
> example :
> 
> function SubmitDefault() {
> form.action.value = "MyDefaultPortletAction";
> form.template.value = "MyDefaultTemplate.vm" ;
> }
> 
> function SubmitToUpdate() {
> form.action.value = "MyUpdatePortletAction";
> form.template.value = "MyUpdateTemplate.vm" ;
> }
> ...
> What are the reasons to use several action and template variables ?
> 

You probably don't want to do this in JS, for 3 reasons:
- you don't trust your client (and if you do, you should not :)
- you can't guarantee that your client will actually execute the
  code
- you break the MVC pattern by encoding controller information 
  in your template and tying your different templates together

IMO, you should never explicitely set a template from another
one but always abstract your application flow through a "state"
that is mapped to a template view by your controller code.
It also makes it much easier to validate the current state of the
application.

--
Raphaël Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Flow and State of a portlet

2003-01-28 Thread Jean-Christophe Kermagoret
It's possible to have this kind of behaviour with a javascript function 
that values the "action" and "template" parameter for each case. For 
example :

function SubmitDefault() {
   form.action.value = "MyDefaultPortletAction";
   form.template.value = "MyDefaultTemplate.vm" ;
}

function SubmitToUpdate() {
   form.action.value = "MyUpdatePortletAction";
   form.template.value = "MyUpdateTemplate.vm" ;
}
...
What are the reasons to use several action and template variables ?

[EMAIL PROTECTED] wrote:

This seems great..  What is the argument against just makeing this part of
the VelocityPortlet?  Currently I have a single .vm file and a huge case
statement to deal with the various screens, very crufty!

Eric

-Original Message-
From: Luta, Raphael (VUN) [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 5:51 AM
To: 'Jetspeed Users List'
Subject: RE: Flow and State of a portlet


De : Wei Guan [mailto:[EMAIL PROTECTED]]
 

First, I would like to say: Great job.

I am still puzzling on how to build highly-interactive 
portlet. Here is a user case:
1) the default template is page1.vm rendering default data 
prepared by buildNormalConent of Action1.java
2) on page1.vm, there are couple of links, each link will 
result an action, generate different data and need diifferent 
templates to render. For example, there is a link "link1" on page1.vm:
   page1.vm ---link1--->method in action1>page2.vm.

I think this is the sequence in JetSpeed
1) action1.buildNormalContent ---> page1.vm
2) --->link1--->method in action1 
-->action1.buildNormalContent--->action1.setTempate(page2.vm)-
-->page2.vm.

I am looking for a solution like this.
1) action1.buildNormalContent ---> page1.vm
2) --->link1--->method in action2 
-->action2.buildNormalContent--->action2.setTempate(page2.vm)-
-->page2.vm.

   


This is not possible in the default VelocityPortlet but it's very easy 
to implement.

For example:
Assumption: you can define a new non-conflicting parameter name
that will handle the state of your portlet, let's say "pstate".

1-  Update your portlet Regsitry definition to have:
 
  
  
  
  
  
  
   etc...

2- Apply the following patch to VelocityPortlet:

Index: VelocityPortlet.java
===
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/Velo
cityPortlet.java,v
retrieving revision 1.20
diff -r1.20 VelocityPortlet.java
159c159,170
< String template = getPortletConfig().getInitParameter("template");
---
 

   String state = data.getParameters().getString("pstate");
   
   String templateName = "template";
   String actionName = "action";
   
   if ((state != null) && (!state.equals("")))
   {
   templateName = templateName + "." + state;
   actionName = actionName + "." + state;
   }
   
   String template =
   

getPortletConfig().getInitParameter(templateName);
181c192
< String actionName = getPortletConfig().getInitParameter("action");
---
 

   String actionName =
   

getPortletConfig().getInitParameter(actionName);


Et voila, your portlet now gives you basic built-in controller capabilities
so that you don't even have to use "setTemplate" unless you want to 
redirect your user to a non-standard state template, plus you would have the

following flow control:

- page1.vm
- link1
- actionX.doEvent (depends on the "action" paramater included in the link)
- go to state 2
- action2.buildContext
- page2.vm


--
Raphaël Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

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

 




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




RE: Flow and State of a portlet

2003-01-27 Thread EPugh
This seems great..  What is the argument against just makeing this part of
the VelocityPortlet?  Currently I have a single .vm file and a huge case
statement to deal with the various screens, very crufty!

Eric

-Original Message-
From: Luta, Raphael (VUN) [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 5:51 AM
To: 'Jetspeed Users List'
Subject: RE: Flow and State of a portlet


De : Wei Guan [mailto:[EMAIL PROTECTED]]
> 
> First, I would like to say: Great job.
> 
> I am still puzzling on how to build highly-interactive 
> portlet. Here is a user case:
> 1) the default template is page1.vm rendering default data 
> prepared by buildNormalConent of Action1.java
> 2) on page1.vm, there are couple of links, each link will 
> result an action, generate different data and need diifferent 
> templates to render. For example, there is a link "link1" on page1.vm:
> page1.vm ---link1--->method in action1>page2.vm.
> 
> I think this is the sequence in JetSpeed
> 1) action1.buildNormalContent ---> page1.vm
> 2) --->link1--->method in action1 
> -->action1.buildNormalContent--->action1.setTempate(page2.vm)-
> -->page2.vm.
> 
> I am looking for a solution like this.
> 1) action1.buildNormalContent ---> page1.vm
> 2) --->link1--->method in action2 
> -->action2.buildNormalContent--->action2.setTempate(page2.vm)-
> -->page2.vm.
> 

This is not possible in the default VelocityPortlet but it's very easy 
to implement.

For example:
Assumption: you can define a new non-conflicting parameter name
that will handle the state of your portlet, let's say "pstate".

1-  Update your portlet Regsitry definition to have:
  
   
   
   
   
   
   
etc...

2- Apply the following patch to VelocityPortlet:

Index: VelocityPortlet.java
===
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/Velo
cityPortlet.java,v
retrieving revision 1.20
diff -r1.20 VelocityPortlet.java
159c159,170
< String template = getPortletConfig().getInitParameter("template");
---
> String state = data.getParameters().getString("pstate");
> 
> String templateName = "template";
> String actionName = "action";
> 
> if ((state != null) && (!state.equals("")))
> {
> templateName = templateName + "." + state;
> actionName = actionName + "." + state;
> }
> 
> String template =
getPortletConfig().getInitParameter(templateName);
181c192
< String actionName = getPortletConfig().getInitParameter("action");
---
> String actionName =
getPortletConfig().getInitParameter(actionName);


Et voila, your portlet now gives you basic built-in controller capabilities
so that you don't even have to use "setTemplate" unless you want to 
redirect your user to a non-standard state template, plus you would have the

following flow control:

- page1.vm
- link1
- actionX.doEvent (depends on the "action" paramater included in the link)
- go to state 2
- action2.buildContext
- page2.vm


--
Raphaël Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

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



RE: Flow and State of a portlet

2003-01-27 Thread Luta, Raphael (VUN)
De : Wei Guan [mailto:[EMAIL PROTECTED]]
> 
> First, I would like to say: Great job.
> 
> I am still puzzling on how to build highly-interactive 
> portlet. Here is a user case:
> 1) the default template is page1.vm rendering default data 
> prepared by buildNormalConent of Action1.java
> 2) on page1.vm, there are couple of links, each link will 
> result an action, generate different data and need diifferent 
> templates to render. For example, there is a link "link1" on page1.vm:
> page1.vm ---link1--->method in action1>page2.vm.
> 
> I think this is the sequence in JetSpeed
> 1) action1.buildNormalContent ---> page1.vm
> 2) --->link1--->method in action1 
> -->action1.buildNormalContent--->action1.setTempate(page2.vm)-
> -->page2.vm.
> 
> I am looking for a solution like this.
> 1) action1.buildNormalContent ---> page1.vm
> 2) --->link1--->method in action2 
> -->action2.buildNormalContent--->action2.setTempate(page2.vm)-
> -->page2.vm.
> 

This is not possible in the default VelocityPortlet but it's very easy 
to implement.

For example:
Assumption: you can define a new non-conflicting parameter name
that will handle the state of your portlet, let's say "pstate".

1-  Update your portlet Regsitry definition to have:
  
   
   
   
   
   
   
etc...

2- Apply the following patch to VelocityPortlet:

Index: VelocityPortlet.java
===
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/Velo
cityPortlet.java,v
retrieving revision 1.20
diff -r1.20 VelocityPortlet.java
159c159,170
< String template = getPortletConfig().getInitParameter("template");
---
> String state = data.getParameters().getString("pstate");
> 
> String templateName = "template";
> String actionName = "action";
> 
> if ((state != null) && (!state.equals("")))
> {
> templateName = templateName + "." + state;
> actionName = actionName + "." + state;
> }
> 
> String template =
getPortletConfig().getInitParameter(templateName);
181c192
< String actionName = getPortletConfig().getInitParameter("action");
---
> String actionName =
getPortletConfig().getInitParameter(actionName);


Et voila, your portlet now gives you basic built-in controller capabilities
so that you don't even have to use "setTemplate" unless you want to 
redirect your user to a non-standard state template, plus you would have the

following flow control:

- page1.vm
- link1
- actionX.doEvent (depends on the "action" paramater included in the link)
- go to state 2
- action2.buildContext
- page2.vm


--
Raphaël Luta - [EMAIL PROTECTED]
Jakarta Jetspeed - Enterprise Portal in Java
http://jakarta.apache.org/jetspeed/

--
To unsubscribe, e-mail:   
For additional commands, e-mail: