RE: Different content for user

2008-03-13 Thread Warren
Take a look at Wicket-Security at Wicket Stuff site.

http://wicketstuff.org/confluence/display/STUFFWIKI/Wicket-Security

I am using it to do the same types of things you are talking about, and it
works great.

 -Original Message-
 From: Mathias P.W Nilsson [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 13, 2008 8:11 AM
 To: users@wicket.apache.org
 Subject: Different content for user



 How can I show different content for logged in users.

 I have a DataSheet page that allows users to add to cart, edit and so on.
 Some users should not be able to edit the content or even add to cart. How
 can I achive this?
 --
 View this message in context:
 http://www.nabble.com/Different-content-for-user-tp16027844p16027844.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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



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



Re: Different content for user

2008-03-13 Thread Igor Vaynberg
if (condition) add component is static - if you put it into
constructor it is only evaluated once, so if login status changes in
the middle of the lifecyle of the panel it will not reflect the
change.

personally something like

add(new loggedinpanel(..) { isvisible() { return isuserloggedin(); } });
add(new notloggedinpanel(..) { isvisible() { return !isuserloggedin(); }});

works much better

if these panels contain a lot of components, or components that are
expensive to construct, you can add the appropriate one in
obeforerender

onbeforerender() {
   if (loggedin()) {
 if (get(panel)==null) add(new loggedinpanel(panel);
 else if (!get(panel) instanceof loggedinpanel) {
get(panel).replacewith(new loggedinpanel(panel); }
  } else {
 if (get(panel)==null) add(new loggedoutpanel(panel);
 else if (!get(panel) instanceof loggedoutpanel) {
get(panel).replacewith(new loggedoutpanel(panel); }
}

-igor


   if (isuserloggedin()) { add(new loggedinpanel

On Thu, Mar 13, 2008 at 11:25 AM, Mathias P.W Nilsson
[EMAIL PROTECTED] wrote:

  Ehh looks complicated. What about the old if( condition ) add Component ?
  --
  View this message in context: 
 http://www.nabble.com/Different-content-for-user-tp16027844p16034721.html


 Sent from the Wicket - User mailing list archive at Nabble.com.


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



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



Re: Different content for user

2008-03-13 Thread James Carman
Tapestry has an actual If component.  Would that work in Wicket?

On 3/13/08, Igor Vaynberg [EMAIL PROTECTED] wrote:
 if (condition) add component is static - if you put it into
  constructor it is only evaluated once, so if login status changes in
  the middle of the lifecyle of the panel it will not reflect the
  change.

  personally something like

  add(new loggedinpanel(..) { isvisible() { return isuserloggedin(); } });
  add(new notloggedinpanel(..) { isvisible() { return !isuserloggedin(); }});

  works much better

  if these panels contain a lot of components, or components that are
  expensive to construct, you can add the appropriate one in
  obeforerender

  onbeforerender() {
if (loggedin()) {
  if (get(panel)==null) add(new loggedinpanel(panel);
  else if (!get(panel) instanceof loggedinpanel) {
  get(panel).replacewith(new loggedinpanel(panel); }
   } else {
  if (get(panel)==null) add(new loggedoutpanel(panel);
  else if (!get(panel) instanceof loggedoutpanel) {
  get(panel).replacewith(new loggedoutpanel(panel); }
  }

  -igor


if (isuserloggedin()) { add(new loggedinpanel


  On Thu, Mar 13, 2008 at 11:25 AM, Mathias P.W Nilsson
  [EMAIL PROTECTED] wrote:
  
Ehh looks complicated. What about the old if( condition ) add 
 Component ?
--
View this message in context: 
 http://www.nabble.com/Different-content-for-user-tp16027844p16034721.html
  
  
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
  
  

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



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



Re: Different content for user

2008-03-13 Thread Igor Vaynberg
yep, you can write something like tapestry's if, it would look very
much like the onbeforerender stuff i wrote below...

-igor


On Thu, Mar 13, 2008 at 11:38 AM, James Carman
[EMAIL PROTECTED] wrote:
 Tapestry has an actual If component.  Would that work in Wicket?



  On 3/13/08, Igor Vaynberg [EMAIL PROTECTED] wrote:
   if (condition) add component is static - if you put it into
constructor it is only evaluated once, so if login status changes in
the middle of the lifecyle of the panel it will not reflect the
change.
  
personally something like
  
add(new loggedinpanel(..) { isvisible() { return isuserloggedin(); } });
add(new notloggedinpanel(..) { isvisible() { return !isuserloggedin(); 
 }});
  
works much better
  
if these panels contain a lot of components, or components that are
expensive to construct, you can add the appropriate one in
obeforerender
  
onbeforerender() {
  if (loggedin()) {
if (get(panel)==null) add(new loggedinpanel(panel);
else if (!get(panel) instanceof loggedinpanel) {
get(panel).replacewith(new loggedinpanel(panel); }
 } else {
if (get(panel)==null) add(new loggedoutpanel(panel);
else if (!get(panel) instanceof loggedoutpanel) {
get(panel).replacewith(new loggedoutpanel(panel); }
}
  
-igor
  
  
  if (isuserloggedin()) { add(new loggedinpanel
  
  
On Thu, Mar 13, 2008 at 11:25 AM, Mathias P.W Nilsson
[EMAIL PROTECTED] wrote:

  Ehh looks complicated. What about the old if( condition ) add 
 Component ?
  --
  View this message in context: 
 http://www.nabble.com/Different-content-for-user-tp16027844p16034721.html


 Sent from the Wicket - User mailing list archive at Nabble.com.


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


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

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



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



Re: Different content for user

2008-03-13 Thread Mathias P.W Nilsson

Thanks!

I'm really confused on what to do here. What is your approach to this?
-- 
View this message in context: 
http://www.nabble.com/Different-content-for-user-tp16027844p16036638.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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