Re: Adding/Replacing links in Panels

2009-02-13 Thread Mathias P.W Nilsson

Hi,

I guess there could be other ways to do this better. Try using break after
each case. 

switch( comp ){
  case ROLE:
break;
}

If you don't use break the link will be added twice
-- 
View this message in context: 
http://www.nabble.com/Adding-Replacing-links-in-Panels-tp21989041p21994847.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Adding/Replacing links in Panels

2009-02-13 Thread Michael Sparer

personally I'm no fan of conditional adding components with the same id.
e.g.
if (user.isSignedIn() {
add(new SignedInPanel(foo));
else {
add(new SignedOutPanel(foo));
}

I rather add all panels and make them invisible or visible

add(new SignedInPanel(foo).setVisible(user.isSignedIn()); // or override
isvisible if that may change ...
add(new SignedOutPanel(bar).setVisible(!user.isSignedIn()); 

this way you always know which panels are added to the page and what they
are ...

regards,
Michael


ashtek wrote:
 
 Hey All,
 
   I apologize for the long content -
   
   I have a navigation bar on the side that contains links to add Users,
 Permissions, Roles, etc... When a user clicks on a navigation link (say
 Users), a Users home page is displayed that contains a link to add users,
 and a list of all available users. 
   
   The link to add users is a panel that contains 
   
   wicket:link
   td #  Add Users  /td
   /wicket:link
   
   
   In each of the home pages I add the panel like this -
   
 On the User home page I add,  add(new AddPanel(addPanel,
 AddPanel.USER));
 
 On the Roles home page I add,  add(new AddPanel(addPanel,
 AddPanel.ROLES));
 
 
  And this is what I have in the AddPanel.class
  
   public AddPanel(String id, int addWhat) {
   super(id);
   
   switch (addWhat) {
   case USER:
   add(new BookmarkablePageLink(addLink, 
 EditUsers.class));
   case ROLES:
   case PERMISSIONS:
   add(new BookmarkablePageLink(addLink, 
 EditPermissions.class));
   default:
   }
   
   
 The Problem is, when I click on the Users homepage, and then I click on
 the Permissions home page, I get an error saying addLink already exists
 in the markup. Is there a better way to handle links than this?  
 
 Thanks!
 


-
Michael Sparer
http://techblog.molindo.at
-- 
View this message in context: 
http://www.nabble.com/Adding-Replacing-links-in-Panels-tp21989041p21995364.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Adding/Replacing links in Panels

2009-02-13 Thread ashtek

Yes, but in my case, I dont need separate panels (the only variable being the
link, and everything else remains constant). I might then as well include
the markup in each of the files.


Michael Sparer wrote:
 
 personally I'm no fan of conditional adding components with the same id.
 e.g.
 if (user.isSignedIn() {
 add(new SignedInPanel(foo));
 else {
 add(new SignedOutPanel(foo));
 }
 
 I rather add all panels and make them invisible or visible
 
 add(new SignedInPanel(foo).setVisible(user.isSignedIn()); // or override
 isvisible if that may change ...
 add(new SignedOutPanel(bar).setVisible(!user.isSignedIn()); 
 
 this way you always know which panels are added to the page and what they
 are ...
 
 regards,
 Michael
 
 
 ashtek wrote:
 
 Hey All,
 
   I apologize for the long content -
   
   I have a navigation bar on the side that contains links to add Users,
 Permissions, Roles, etc... When a user clicks on a navigation link (say
 Users), a Users home page is displayed that contains a link to add users,
 and a list of all available users. 
   
   The link to add users is a panel that contains 
   
   wicket:link
  td #  Add Users  /td
   /wicket:link
   
   
   In each of the home pages I add the panel like this -
   
 On the User home page I add,  add(new AddPanel(addPanel,
 AddPanel.USER));
 
 On the Roles home page I add,  add(new AddPanel(addPanel,
 AddPanel.ROLES));
 
 
  And this is what I have in the AddPanel.class
  
  public AddPanel(String id, int addWhat) {
  super(id);
  
  switch (addWhat) {
  case USER:
  add(new BookmarkablePageLink(addLink, 
 EditUsers.class));
  case ROLES:
  case PERMISSIONS:
  add(new BookmarkablePageLink(addLink, 
 EditPermissions.class));
  default:
  }
  
  
 The Problem is, when I click on the Users homepage, and then I click on
 the Permissions home page, I get an error saying addLink already exists
 in the markup. Is there a better way to handle links than this? 
 
 Thanks!
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Adding-Replacing-links-in-Panels-tp21989041p21995664.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Adding/Replacing links in Panels

2009-02-13 Thread ashtek

Thanks Mathias. That was it. :) The links render properly now.
-- 
View this message in context: 
http://www.nabble.com/Adding-Replacing-links-in-Panels-tp21989041p21995675.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Adding/Replacing links in Panels

2009-02-12 Thread ashtek

Hey All,

  I apologize for the long content -
  
  I have a navigation bar on the side that contains links to add Users,
Permissions, Roles, etc... When a user clicks on a navigation link (say
Users), a Users home page is displayed that contains a link to add users,
and a list of all available users. 
  
  The link to add users is a panel that contains 
  
  wicket:link
td #  Add Users  /td
  /wicket:link
  
  
  In each of the home pages I add the panel like this -
  
On the User home page I add,  add(new AddPanel(addPanel, AddPanel.USER));

On the Roles home page I add,  add(new AddPanel(addPanel,
AddPanel.ROLES));


 And this is what I have in the AddPanel.class
 
public AddPanel(String id, int addWhat) {
super(id);

switch (addWhat) {
case USER:
add(new BookmarkablePageLink(addLink, 
EditUsers.class));
case ROLES:
case PERMISSIONS:
add(new BookmarkablePageLink(addLink, 
EditPermissions.class));
default:
}


The Problem is, when I click on the Users homepage, and then I click on the
Permissions home page, I get an error saying addLink already exists in the
markup. Is there a better way to handle links than this?   

Thanks!
-- 
View this message in context: 
http://www.nabble.com/Adding-Replacing-links-in-Panels-tp21989041p21989041.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org