Empy choices durring unit tests with DropDownChoice

2013-06-17 Thread Dmitriy Neretin
Hi everyone!

I have a little problem. When I unit test a wicket panel with a
DropDownChoice I can't get the choices list into dropdown... So, that is
how I use it:

a) ... new DropDownChoice(aWicketId, new ChoicesModel.getObject(),
myOwnChoicesRenderer)

b) The choices Model ist a loadabledetachablemodel. In the load Method a
have a service call, that returns a list of choices:

load(){
   myService.getChoicesList()
}

c) In the unit test itself I start the panel with:

Mockito.when(myService.getChoicesList()).thenReturn(mockedChoicesList)

tester.startComponentInThePage(MyPanel.class)...

and somewhere on the bottom of the test:

tester.getComponentFromLastRenderedPage(dropDownId).getChoices and ...
nothing happens... The mocked choices are away...

Can somebody explain me, what do I wrong?

Regards,
Dmitriy


Re: Wicket context menu component

2013-06-17 Thread bronius
Hi Sebastien,

Thats great news, I prefer to use library version as it has a lot of
advantages over rolling my own solution. I tried yours and it works fine for
me. I think example of how to recognize which link was clicked in demo would
be helpful for others, as context menu will certainly need this for real
world scenario. Here how I did it (let me know if thats how its intended to
use):
final ContextMenu menu = new ContextMenu(menu, Arrays.asList(menuItem1,
menuItem2, menuItem3, menuItem4)) {

private static final long serialVersionUID = 1L;

private AjaxFallbackLinkUser selectedLink = null;

@SuppressWarnings(unchecked)
@Override
protected void onContextMenu(AjaxRequestTarget target, Component
component)
{
selectedLink = ((AjaxFallbackLinkUser)component);
}

@Override
public void onClick(AjaxRequestTarget target, IMenuItem item)
{
switch (item.getTitle().getObject()) {
case Context menu 1:
if (selectedLink != null) {
selectedLink.onClick(target);
}
break;
case Context menu 2:
System.out.println(Clicked  +
item.getTitle().getObject() +  on  +
selectedLink.getModelObject().getNickname());
break;
case Context menu 3:
System.out.println(Clicked  +
item.getTitle().getObject() +  on  +
selectedLink.getModelObject().getNickname());
break;
case Context menu 4:
System.out.println(Clicked  +
item.getTitle().getObject() +  on  +
selectedLink.getModelObject().getNickname());
break;
}
}
};

Big thanks and best regards! :)

bronius



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-context-menu-component-tp4659306p4659541.html
Sent from the Users forum 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: Wicket context menu component

2013-06-17 Thread Sebastien
Hi Bronius,

You're welcome!

Yes, the usage you performed is the intended one. In your case however,
maybe you can optimize it, because when a menu-item is clicked, both
IMenuItem#onClick() and Menu#onClick() are triggered (in that order). So
instead of a 'switch' statement in Menu#onClick(), you can implement the
IMenuItem(s)#onClick().
For instance, if you extend the ContextMenu to a dedicated class (embedding
the selectedLink member, the menu-items and their #onClick), then you'll
have a nicer code IMO...

Thanks  best regards,
Sebastien.


On Mon, Jun 17, 2013 at 1:58 PM, bronius keptavi...@gmail.com wrote:

 Hi Sebastien,

 Thats great news, I prefer to use library version as it has a lot of
 advantages over rolling my own solution. I tried yours and it works fine
 for
 me. I think example of how to recognize which link was clicked in demo
 would
 be helpful for others, as context menu will certainly need this for real
 world scenario. Here how I did it (let me know if thats how its intended to
 use):
 final ContextMenu menu = new ContextMenu(menu, Arrays.asList(menuItem1,
 menuItem2, menuItem3, menuItem4)) {

 private static final long serialVersionUID = 1L;

 private AjaxFallbackLinkUser selectedLink = null;

 @SuppressWarnings(unchecked)
 @Override
 protected void onContextMenu(AjaxRequestTarget target,
 Component
 component)
 {
 selectedLink = ((AjaxFallbackLinkUser)component);
 }

 @Override
 public void onClick(AjaxRequestTarget target, IMenuItem item)
 {
 switch (item.getTitle().getObject()) {
 case Context menu 1:
 if (selectedLink != null) {
 selectedLink.onClick(target);
 }
 break;
 case Context menu 2:
 System.out.println(Clicked  +
 item.getTitle().getObject() +  on  +
 selectedLink.getModelObject().getNickname());
 break;
 case Context menu 3:
 System.out.println(Clicked  +
 item.getTitle().getObject() +  on  +
 selectedLink.getModelObject().getNickname());
 break;
 case Context menu 4:
 System.out.println(Clicked  +
 item.getTitle().getObject() +  on  +
 selectedLink.getModelObject().getNickname());
 break;
 }
 }
 };

 Big thanks and best regards! :)

 bronius



Haritha Juturu

2013-06-17 Thread Haritha Juturu
wer
http://www.technicboisnouvelle.fr/uk/tkqrgioxcqp/pxztowtdx/unyjzl.php
Haritha Juturu


Re: Wicket context menu component

2013-06-17 Thread bronius
Yes I agree, thanks again :)



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-context-menu-component-tp4659306p4659544.html
Sent from the Users forum 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: Form submit without redirection

2013-06-17 Thread divad91
Hi thanks for your response.

The errors that I want to send back are my form business error.
I use jQuery validate to do my frontend validation and to display them. We
build a custom plugin to display the business errors the same way the
frontend errors are displayed.
So basically, I send back a list of business errors to a javascript template
that will merge these errors to the jQuery validation plugin. (each errors
are recorded to a specific field).

I know I should not pass page parameters but this is how the they manage to
do it in wicket 1.4.2 and there were not passed in the URL (get)...

So I will do a little refactoring.. Where should I keep my error list to
send to the same page  ?
Session or Metadata or else ?

thanks
David



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Form-submit-without-redirection-tp4659496p4659547.html
Sent from the Users forum 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



Server side caching of generated resources

2013-06-17 Thread Thomas Heigl
Hi all,

I was wondering if Wicket has a built-in mechanism for caching the
generated byte[] of package resources. I use concatenated resource bundles
that are compressed using the YUI CSS/JS compressors.

Using the default settings, compression is performed for every request that
does not have it in the client cache. Since this compression is a very
complex operation I'd like to perform it only once.

Cheers,

Thomas


Re: Server side caching of generated resources

2013-06-17 Thread Michael Haitz
Hi Thomas,

it depends on your deployment mode:

 if (application.usesDevelopmentConfig())
{
// development mode:
// use last-modified timestamp of packaged resource for resource caching
// cache the version information for the lifetime of the current http 
request
resourceVersion = new RequestCycleCachedResourceVersion(
new LastModifiedResourceVersion());
}
else
{
// deployment mode:
// use message digest over resource content for resource caching
// cache the version information for the lifetime of the application
resourceVersion = new CachingResourceVersion(new 
MessageDigestResourceVersion());
}

best,
Michael


Am 17.06.2013 um 15:21 schrieb Thomas Heigl tho...@umschalt.com:

 Hi all,
 
 I was wondering if Wicket has a built-in mechanism for caching the
 generated byte[] of package resources. I use concatenated resource bundles
 that are compressed using the YUI CSS/JS compressors.
 
 Using the default settings, compression is performed for every request that
 does not have it in the client cache. Since this compression is a very
 complex operation I'd like to perform it only once.
 
 Cheers,
 
 Thomas


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



Re: Server side caching of generated resources

2013-06-17 Thread Thomas Heigl
Hi Michael,

This caches only the resource version, e.g. message digest, but not the
actual contents of the resouce.

Kind regards,

Thomas


On Mon, Jun 17, 2013 at 4:02 PM, Michael Haitz michael.ha...@1und1.dewrote:

 Hi Thomas,

 it depends on your deployment mode:

  if (application.usesDevelopmentConfig())
 {
 // development mode:
 // use last-modified timestamp of packaged resource for resource
 caching
 // cache the version information for the lifetime of the current
 http request
 resourceVersion = new RequestCycleCachedResourceVersion(
 new LastModifiedResourceVersion());
 }
 else
 {
 // deployment mode:
 // use message digest over resource content for resource caching
 // cache the version information for the lifetime of the
 application
 resourceVersion = new CachingResourceVersion(new
 MessageDigestResourceVersion());
 }

 best,
 Michael


 Am 17.06.2013 um 15:21 schrieb Thomas Heigl tho...@umschalt.com:

  Hi all,
 
  I was wondering if Wicket has a built-in mechanism for caching the
  generated byte[] of package resources. I use concatenated resource
 bundles
  that are compressed using the YUI CSS/JS compressors.
 
  Using the default settings, compression is performed for every request
 that
  does not have it in the client cache. Since this compression is a very
  complex operation I'd like to perform it only once.
 
  Cheers,
 
  Thomas


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




Re: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread David Solum
Hi,

As I said in my original post, that markup works, but the
BookmarkablePageLinks that I add are rendered as div tags with onclick
handlers.  I am trying to get anchor tags.

I believe the post that Sven referred to is a step in the right direction,
but my markup gives me the unclosed tag error.

Has anyone gotten a BookmarkablePageLink to render as an anchor tag?  If so,
may I see the markup you used?  Thank you very much in advance.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502p4659551.html
Sent from the Users forum 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: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread Martin Grigorov
Show us your new markup.


On Mon, Jun 17, 2013 at 5:09 PM, David Solum djso...@yahoo.com wrote:

 Hi,

 As I said in my original post, that markup works, but the
 BookmarkablePageLinks that I add are rendered as div tags with onclick
 handlers.  I am trying to get anchor tags.

 I believe the post that Sven referred to is a step in the right direction,
 but my markup gives me the unclosed tag error.

 Has anyone gotten a BookmarkablePageLink to render as an anchor tag?  If
 so,
 may I see the markup you used?  Thank you very much in advance.



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502p4659551.html
 Sent from the Users forum 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: Server side caching of generated resources

2013-06-17 Thread Martin Grigorov
Hi,

At the moment there is no caching of the content.
The only library that does such kind of caching is
wicket-bootstrap:bootstrap-less (
https://github.com/l0rdn1kk0n/wicket-bootstrap/tree/master/bootstrap-less/src/main/java/de/agilecoders/wicket/less
)


On Mon, Jun 17, 2013 at 5:06 PM, Thomas Heigl tho...@umschalt.com wrote:

 Hi Michael,

 This caches only the resource version, e.g. message digest, but not the
 actual contents of the resouce.

 Kind regards,

 Thomas


 On Mon, Jun 17, 2013 at 4:02 PM, Michael Haitz michael.ha...@1und1.de
 wrote:

  Hi Thomas,
 
  it depends on your deployment mode:
 
   if (application.usesDevelopmentConfig())
  {
  // development mode:
  // use last-modified timestamp of packaged resource for resource
  caching
  // cache the version information for the lifetime of the current
  http request
  resourceVersion = new RequestCycleCachedResourceVersion(
  new LastModifiedResourceVersion());
  }
  else
  {
  // deployment mode:
  // use message digest over resource content for resource caching
  // cache the version information for the lifetime of the
  application
  resourceVersion = new CachingResourceVersion(new
  MessageDigestResourceVersion());
  }
 
  best,
  Michael
 
 
  Am 17.06.2013 um 15:21 schrieb Thomas Heigl tho...@umschalt.com:
 
   Hi all,
  
   I was wondering if Wicket has a built-in mechanism for caching the
   generated byte[] of package resources. I use concatenated resource
  bundles
   that are compressed using the YUI CSS/JS compressors.
  
   Using the default settings, compression is performed for every request
  that
   does not have it in the client cache. Since this compression is a very
   complex operation I'd like to perform it only once.
  
   Cheers,
  
   Thomas
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 



Re: Server side caching of generated resources

2013-06-17 Thread Michael Haitz
Hi,

but isn't it enough to send the correct cache headers + a calculated filename 
that contains the hash of file? 
I think caching on your container isn't the best option (using nginx or varnish 
or a CDN like Akamai or something similar is way better), else you've to 
compile each resource on all your containers and you need some heap space for 
the content.

best,
Michael

Am 17.06.2013 um 16:02 schrieb Michael Haitz michael.ha...@1und1.de
:

 Hi Thomas,
 
 it depends on your deployment mode:
 
 if (application.usesDevelopmentConfig())
 {
   // development mode:
   // use last-modified timestamp of packaged resource for resource caching
   // cache the version information for the lifetime of the current http 
 request
   resourceVersion = new RequestCycleCachedResourceVersion(
   new LastModifiedResourceVersion());
 }
 else
 {
   // deployment mode:
   // use message digest over resource content for resource caching
   // cache the version information for the lifetime of the application
   resourceVersion = new CachingResourceVersion(new 
 MessageDigestResourceVersion());
 }
 
 best,
 Michael
 
 
 Am 17.06.2013 um 15:21 schrieb Thomas Heigl tho...@umschalt.com:
 
 Hi all,
 
 I was wondering if Wicket has a built-in mechanism for caching the
 generated byte[] of package resources. I use concatenated resource bundles
 that are compressed using the YUI CSS/JS compressors.
 
 Using the default settings, compression is performed for every request that
 does not have it in the client cache. Since this compression is a very
 complex operation I'd like to perform it only once.
 
 Cheers,
 
 Thomas
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


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



Re: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread David Solum
Here is the simplest thing I've tried: 

 wicket:panel 
 table wicket:id=dataTable border=0 cellpadding=1
cellspacing=1 width=90% 
 a href=# wicket:id=link /a 
 /table 
 /wicket:panel 

(I added the spaces after the angled brackets just for posting, they are not
part of the markup in my code.)



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502p4659556.html
Sent from the Users forum 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: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread Martin Grigorov
You have to use just table wicket:id=... .../table for the DataTable.
And a separate markup for the cell content. For example with a Fragment:
wicket:fragment id=linkFragmenta
wicket:id=link/a/wicket:fragment
Or use Panel if you don't have experience with Fragments


On Mon, Jun 17, 2013 at 6:19 PM, David Solum djso...@yahoo.com wrote:

 Here is the simplest thing I've tried:

  wicket:panel
  table wicket:id=dataTable border=0 cellpadding=1
 cellspacing=1 width=90%
  a href=# wicket:id=link /a
  /table
  /wicket:panel

 (I added the spaces after the angled brackets just for posting, they are
 not
 part of the markup in my code.)



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502p4659556.html
 Sent from the Users forum 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: Server side caching of generated resources

2013-06-17 Thread Thomas Heigl
Hey Michael,

but isn't it enough to send the correct cache headers + a calculated
 filename that contains the hash of file?


I actually have aggressive caching and a CDN in front of my resources. So
in 90% of cases, a resource is only generated once per deployment. My
problem is that I need to fetch some resources directly from my origin to
support media queries for IE=8 and avoid running into cross-domain issues.
So between 5 and 10% of users directly hit my origin for CSS resources and
the load generated by this is getting too high.

Thanks a lot for your suggestions. I'll try to think of a solution that
does not involve Wicket.

Cheers,

Thomas



On Mon, Jun 17, 2013 at 4:57 PM, Michael Haitz michael.ha...@1und1.dewrote:

 Hi,

 but isn't it enough to send the correct cache headers + a calculated
 filename that contains the hash of file?
 I think caching on your container isn't the best option (using nginx or
 varnish or a CDN like Akamai or something similar is way better), else
 you've to compile each resource on all your containers and you need some
 heap space for the content.

 best,
 Michael

 Am 17.06.2013 um 16:02 schrieb Michael Haitz michael.ha...@1und1.de
 :

  Hi Thomas,
 
  it depends on your deployment mode:
 
  if (application.usesDevelopmentConfig())
  {
// development mode:
// use last-modified timestamp of packaged resource for resource
 caching
// cache the version information for the lifetime of the current
 http request
resourceVersion = new RequestCycleCachedResourceVersion(
new LastModifiedResourceVersion());
  }
  else
  {
// deployment mode:
// use message digest over resource content for resource caching
// cache the version information for the lifetime of the
 application
resourceVersion = new CachingResourceVersion(new
 MessageDigestResourceVersion());
  }
 
  best,
  Michael
 
 
  Am 17.06.2013 um 15:21 schrieb Thomas Heigl tho...@umschalt.com:
 
  Hi all,
 
  I was wondering if Wicket has a built-in mechanism for caching the
  generated byte[] of package resources. I use concatenated resource
 bundles
  that are compressed using the YUI CSS/JS compressors.
 
  Using the default settings, compression is performed for every request
 that
  does not have it in the client cache. Since this compression is a very
  complex operation I'd like to perform it only once.
 
  Cheers,
 
  Thomas
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 


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




Re: Injecting proxy services in page.

2013-06-17 Thread eugenebalt
We've heard that there is a fix for this available in Wicket 1.5.

However, we are stuck with Wicket 1.4.7 and cannot upgrade, for various
reasons. (We're also already using the AnnotationConfigWebApplicationContext
referred to in the previous post.)

Are there any other workarounds for this problem? Is it OK to make the
problem classes implement Serializable just to move past this issue (even
if they are injected with the @SpringBean, and are service classes), or
should we try other workarounds?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Injecting-proxy-services-in-page-tp4659209p4659563.html
Sent from the Users forum 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



Scala

2013-06-17 Thread Michael Pence
Hello again. Is it cool to ask Scala + Wicket questions here, or is there a 
better place for that.

No hate, but I have been so spoiled by Ruby's conciseness, that I would 
struggle to go back to the more verbose (though much, much faster) Java syntax, 
and would prefer Scala for other reasons, as well.
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Scala

2013-06-17 Thread Martin Grigorov
Sure.

We will try to help.


On Mon, Jun 17, 2013 at 11:21 PM, Michael Pence mike.pe...@gmail.comwrote:

 Hello again. Is it cool to ask Scala + Wicket questions here, or is there
 a better place for that.

 No hate, but I have been so spoiled by Ruby's conciseness, that I would
 struggle to go back to the more verbose (though much, much faster) Java
 syntax, and would prefer Scala for other reasons, as well.
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread David Solum
If you're saying to add the fragment tag outside the table tag, I don't get
any errors, but the Links I add are still rendered as div tags with onclick
handlers.  What would tie the BookmarkablePageLinks that I add to the
DefaultDataTable to the anchor tags in your markup?  Thank you.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502p4659570.html
Sent from the Users forum 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: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread Martin Grigorov
Please create a mini application (a quickstart) that shows the problem and
upload it somewhere. Or put it in GitHub/BitBucket.
Then someone of us will fix it and send it back to you.


On Tue, Jun 18, 2013 at 12:25 AM, David Solum djso...@yahoo.com wrote:

 If you're saying to add the fragment tag outside the table tag, I don't get
 any errors, but the Links I add are still rendered as div tags with onclick
 handlers.  What would tie the BookmarkablePageLinks that I add to the
 DefaultDataTable to the anchor tags in your markup?  Thank you.



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502p4659570.html
 Sent from the Users forum 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: How to dynamically add a hyperlink (BookmarkablePageLink) to DefaultDataTable that is rendered as an anchor

2013-06-17 Thread Jesse Long

Hi David,

The IColumn#populateItem method populates a cell in the HTML table. It 
is as if you are adding your components to markup like this:


td wicket:id=xyz/td

If you have that, and you do:

add(new LinkVoid(xyz){...});

then you will have the same results. Why? Because Link was not designed 
to be added to td markup. Actually, it can be added to td, but then 
you get the onclick behaviour you are describing.


What the link Sven sent is trying to say is this: you cant add a Link 
directly to the cellItem. You must create an intermediate component, the 
example shows it as the LinkPanel. The LinkPanel is added to the td, 
and this works nicely. The link panel then makes a markup available, 
and you add the link to that.


I usually use an abstract LinkPanel that has one abstract factory method 
to create the link, so my populateItem method looks like:


cellItem.add(
// adding link panel to cell
new LinkPanelRowType(componentId, rowModel){
// link panel has abstract factory method for link
@Override
protected Component createLink(String componentId, IModelRowType 
model)

{
return new LinkRowType(componentId, model)
{
@Override
public void onClick()
{
getModel().doSomething();
setResponsePage();
}
}.setBody(Model.of(Whatever));
}
});

hth,
Jesse

On 14/06/2013 18:22, David Solum wrote:

I am using Wicket 6.8 and have a sortable DefaultDataTable that gets its
columns programmatically.

The markup to get this table and the dynamically generated columns simple
(I've added spaces so it all shows):

  wicket:panel
  table wicket:id=dataTable border=0 cellpadding=1
cellspacing=1 width=90% / 
  /wicket:panel

All of the columns are generated from a passed in LinkedHashMap of labels
and attributes:

 for (EntryString, String entry : entrySet) {
 final String label = entry.getKey();
 final String attribute = entry.getValue();
 columns.add(new PsPropertyColumn(label, attribute) {

 @Override
 public void populateItem(Item cellItem, String componentId,
IModel model)
 {
 final Object modelObject = model.getObject();
 final Object value = PropertyResolver.getValue(attribute,
modelObject);
 // Add an edit link
 BookmarkablePageLink link = new ...;
 ...
 cellItem.add(link);
 }
 }
 }

 DefaultDataTable table = new DefaultDataTable(dataTable, columns,
dataProvider, MAX_ROWS) {
 ...
 }
 add(table);

So this properly displays as a sortable table with clickable columns that
send the user to the required page.  However, as many posts have mentioned,
this is rendered as a cell with an onclick handler rather than an anchor (
a href=... /) tag. I want the anchor tag for a couple of reasons, one if
which is that I want to add my own onclick handler without having an
existing onclick handler in the way.

I have seen a solution that says to put an anchor tag inside a panel in the
HTML markup, and to add the link inside of a Panel subclass.  Sadly for me
the markup in the examples wasn't complete, and whatever I try (anchor tags,
tr/td tags, panel tags, etc.), I get the same error:

  Last cause: Close tag not found for tag:
. For Components only raw markup is allow in between the tags but not other
Wicket Component. Component: [DefaultDataTable [Component id = dataTable]]

Here is the simplest thing I've tried:

  wicket:panel
  table wicket:id=dataTable border=0 cellpadding=1
cellspacing=1 width=90%
  a href=# wicket:id=link /a
  /table
  /wicket:panel

Again, no success.  I would love to see markup that allows the
BookmarkablePageLinks be rendered insided the DefaultDataTable as anchor
tags.  Thanks in advance for any help.





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-to-dynamically-add-a-hyperlink-BookmarkablePageLink-to-DefaultDataTable-that-is-rendered-as-an-ar-tp4659502.html
Sent from the Users forum 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





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