[Wicket-user] Setting Visible (setVisible) inside onAttach(). Is this Right?

2007-04-24 Thread Francisco Diaz Trepat - gmail

Hi, I have this working code. But I feel I'am mistaking and this is not the
most apropiate place for it.

Very simple, a logout panel (just a link) that on attached sets itself
visible or not. Here is the code.


public class LogoutPanel extends BasePanel {

  /** Creates a new instance of LogoutPanel */
  public LogoutPanel(String id) {
 super(id);
 //Create logout link
 Link cLogoutLink = new Link(logoutLink) {
//Logout action
public void onClick() {
   //Logout
   getWicketSession().logout();

   setResponsePage(Index.class);
}
 };
 //add class attribute.
 cLogoutLink.add(new AttributeModifier(class, true, new
AbstractReadOnlyModel() {
   public Object getObject(Component component) {
   return headerWiteLink;
   }
   }));
 //add the logoutLink
 add(cLogoutLink);
  }

  protected void onAttach() {
 //Verify visible status
 setVisible(getWicketSession().isUserLoggedIn());
  }

}


This works fine, but is it the correct way of doing this?

Some comments on it could really help.

f(t)
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Setting Visible (setVisible) inside onAttach(). Is this Right?

2007-04-24 Thread Francisco Diaz Trepat - gmail

Excelent. That means that isVisible is called every page
refresh?

Thanks

On 4/24/07, Igor Vaynberg [EMAIL PROTECTED] wrote:


change

protected void onAttach() {
  //Verify visible status
  setVisible(getWicketSession().isUserLoggedIn());
   }

to

boolean isVisible() { return getWicketSession().isUserLoggedIn(); }

imho that is better

-igor



On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
wrote:

 Hi, I have this working code. But I feel I'am mistaking and this is not
 the most apropiate place for it.

 Very simple, a logout panel (just a link) that on attached sets itself
 visible or not. Here is the code.


 public class LogoutPanel extends BasePanel {

/** Creates a new instance of LogoutPanel */
public LogoutPanel(String id) {
   super(id);
   //Create logout link
   Link cLogoutLink = new Link(logoutLink) {
  //Logout action
  public void onClick() {
 //Logout
 getWicketSession().logout();

 setResponsePage(Index.class);
  }
   };
   //add class attribute.
   cLogoutLink.add(new AttributeModifier(class, true, new
 AbstractReadOnlyModel() {
 public Object getObject(Component component) {
 return headerWiteLink;
 }
 }));
   //add the logoutLink
   add(cLogoutLink);
}

protected void onAttach() {
   //Verify visible status
   setVisible(getWicketSession().isUserLoggedIn());
}

 }


 This works fine, but is it the correct way of doing this?

 Some comments on it could really help.

 f(t)



 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Setting Visible (setVisible) inside onAttach(). Is this Right?

2007-04-24 Thread Igor Vaynberg

yes, any time the component is rendered

-igor


On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
wrote:


Excelent. That means that isVisible is called every page
refresh?

Thanks

On 4/24/07, Igor Vaynberg [EMAIL PROTECTED] wrote:

 change

 protected void onAttach() {
   //Verify visible status
   setVisible(getWicketSession().isUserLoggedIn());
}

 to

 boolean isVisible() { return getWicketSession().isUserLoggedIn(); }

 imho that is better

 -igor



 On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
 wrote:

  Hi, I have this working code. But I feel I'am mistaking and this is
  not the most apropiate place for it.
 
  Very simple, a logout panel (just a link) that on attached sets itself
  visible or not. Here is the code.
 
 
  public class LogoutPanel extends BasePanel {
 
 /** Creates a new instance of LogoutPanel */
 public LogoutPanel(String id) {
super(id);
//Create logout link
Link cLogoutLink = new Link(logoutLink) {
   //Logout action
   public void onClick() {
  //Logout
  getWicketSession().logout();
 
  setResponsePage(Index.class);
   }
};
//add class attribute.
cLogoutLink.add(new AttributeModifier(class, true, new
  AbstractReadOnlyModel() {
  public Object getObject(Component component) {
  return headerWiteLink;
  }
  }));
//add the logoutLink
add(cLogoutLink);
 }
 
 protected void onAttach() {
//Verify visible status
setVisible(getWicketSession().isUserLoggedIn());
 }
 
  }
 
 
  This works fine, but is it the correct way of doing this?
 
  Some comments on it could really help.
 
  f(t)
 
 
 
  -
  This SF.net email is sponsored by DB2 Express
  Download DB2 Express C - the FREE version of DB2 express and take
  control of your XML. No limits. Just data. Click to get it now.
  http://sourceforge.net/powerbar/db2/
  ___
  Wicket-user mailing list
  Wicket-user@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 


 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Setting Visible (setVisible) inside onAttach(). Is this Right?

2007-04-24 Thread Francisco Diaz Trepat - gmail

Great, thanks Igor.

On 4/24/07, Igor Vaynberg [EMAIL PROTECTED] wrote:


yes, any time the component is rendered

-igor


On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED] 
wrote:

 Excelent. That means that isVisible is called every page
 refresh?

 Thanks

 On 4/24/07, Igor Vaynberg [EMAIL PROTECTED]  wrote:
 
  change
 
  protected void onAttach() {
//Verify visible status
setVisible(getWicketSession().isUserLoggedIn());
 }
 
  to
 
  boolean isVisible() { return getWicketSession().isUserLoggedIn(); }
 
  imho that is better
 
  -igor
 
 
 
  On 4/24/07, Francisco Diaz Trepat - gmail [EMAIL PROTECTED]
  wrote:
 
   Hi, I have this working code. But I feel I'am mistaking and this is
   not the most apropiate place for it.
  
   Very simple, a logout panel (just a link) that on attached sets
   itself visible or not. Here is the code.
  
  
   public class LogoutPanel extends BasePanel {
  
  /** Creates a new instance of LogoutPanel */
  public LogoutPanel(String id) {
 super(id);
 //Create logout link
 Link cLogoutLink = new Link(logoutLink) {
//Logout action
public void onClick() {
   //Logout
   getWicketSession().logout();
  
   setResponsePage(Index.class);
}
 };
 //add class attribute.
 cLogoutLink.add(new AttributeModifier(class, true, new
   AbstractReadOnlyModel() {
   public Object getObject(Component component) {
   return headerWiteLink;
   }
   }));
 //add the logoutLink
 add(cLogoutLink);
  }
  
  protected void onAttach() {
 //Verify visible status
 setVisible(getWicketSession().isUserLoggedIn());
  }
  
   }
  
  
   This works fine, but is it the correct way of doing this?
  
   Some comments on it could really help.
  
   f(t)
  
  
  
   -
   This SF.net email is sponsored by DB2 Express
   Download DB2 Express C - the FREE version of DB2 express and take
   control of your XML. No limits. Just data. Click to get it now.
   http://sourceforge.net/powerbar/db2/
   ___
   Wicket-user mailing list
   Wicket-user@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/wicket-user
  
  
 
 
  -
  This SF.net email is sponsored by DB2 Express
  Download DB2 Express C - the FREE version of DB2 express and take
  control of your XML. No limits. Just data. Click to get it now.
  http://sourceforge.net/powerbar/db2/
  ___
  Wicket-user mailing list
  Wicket-user@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/wicket-user
 
 


 -
 This SF.net email is sponsored by DB2 Express
 Download DB2 Express C - the FREE version of DB2 express and take
 control of your XML. No limits. Just data. Click to get it now.
 http://sourceforge.net/powerbar/db2/
 ___
 Wicket-user mailing list
 Wicket-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/wicket-user



-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user