Using IndicatingAjaxLink to export CSV data - is it the 'Wicket Way'?

2012-03-05 Thread Robert Szmurlo

Hello everyone,
this my first post to the list, so I would like to give many thanks to the 
authors and all contributors to the great Apache Wicket project. We silently 
develop a medium sized application for over two years (at the Warsaw University 
of Technology), and usually we have resolved all issues by searching answers on 
this users group or by googling them. This time I would ask you for 
consultation.

My goal is to provide a download link for CSV data which will be generated 
dynamically and during the time consuming generation I would like to show a 
user an indicator. Like the one the IndicatingAjaxLink class do.

My questions are:

1) Is the following source code created the 'wicket way' or I am breaking 
somewhere else opened door?
The 'trick' I have employed, that I am not sure of, is the redirection to the 
AbstractDefaultAjaxBehaviour in the onClick method of the IndicatingAjaxLink.

2) The problem with this code is that, when I click the download link the 
second time the indicator is not revolving. It is being displayed correctly, 
and hidden on time, and the CSV data is exported correctly. The problem is that 
the indicator is not moving.

Thank you for you assitance in advance,
Robert Szmurlo

Java:

public class HomePage extends WebPage {

private AbstractDefaultAjaxBehavior b;
private String data = null;

public HomePage(final PageParameters parameters) {

final ByteArrayResource bar = new ByteArrayResource(text/csv) {
@Override
public byte[] getData(Attributes attributes) {
byte[] bytes = null;
try {
bytes = data.getBytes();
} catch (Exception e) {
e.printStackTrace();
}
return bytes;
}

@Override
protected void configureResponse(ResourceResponse 
response,Attributes attributes) {
super.configureResponse(response, attributes);
response.setFileName(report.csv);
}

};

add( b = new AbstractDefaultAjaxBehavior() {
@Override
protected void respond(AjaxRequestTarget target) {
getRequestCycle().scheduleRequestHandlerAfterCurrent(new 
ResourceRequestHandler(bar, getPageParameters()));
}
});

add( new IndicatingAjaxLinkVoid(link) {
@Override
public void onClick(AjaxRequestTarget target) {

prepareData(); // takes some time

if (target != null) {
*target.appendJavaScript(window.location=' + b.getCallbackUrl() + ');*
}
}
});
}

protected void prepareData() {
// JUST FOR TEST
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
/

// atach data?
data = No.;Name\n +
   1.;John\n +
   2.;Mary;
}
}


HTML:
html
body
a wicket:id=linkExport CSV/a
/body
/html



Re: Using IndicatingAjaxLink to export CSV data - is it the 'Wicket Way'?

2012-03-05 Thread Robert Szmurlo

Thank you for a super fast response. As far as I can see Meier, Barreiro and 
Deu-Pons applied the same approach
but in a more professional way.

They do:

String  url = getCallbackUrl().toString();
(...)
// the timeout is needed to let Wicket release the channel
target.appendJavaScript(setTimeout(\window.location.href=' + url +'\, 
100););

And I simply do:

 target.appendJavaScript(window.location=' + b.getCallbackUrl() + ');

They have also set the content disposition to the resource handler:

 handler.setContentDisposition(ContentDisposition.ATTACHMENT);

Anyway, thank you for your answer, the link you have attached: 
https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html
is the answer I was looking for.

Robert



W dniu 2012-03-05 16:26, Martin Grigorov pisze:

Hi,

I'm not sure that this really works.
With your code the Ajax request will end with .csv response, not with
ajax-response. The indicator may disappear but the .csv data wont be
presented to the user/browser. It will be swallowed in the ajax
response.

I think you need
https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html

On Mon, Mar 5, 2012 at 5:13 PM, Robert Szmurlorob...@iem.pw.edu.pl  wrote:

Hello everyone,
this my first post to the list, so I would like to give many thanks to the
authors and all contributors to the great Apache Wicket project. We silently
develop a medium sized application for over two years (at the Warsaw
University of Technology), and usually we have resolved all issues by
searching answers on this users group or by googling them. This time I would
ask you for consultation.

My goal is to provide a download link for CSV data which will be generated
dynamically and during the time consuming generation I would like to show a
user an indicator. Like the one the IndicatingAjaxLink class do.

My questions are:

1) Is the following source code created the 'wicket way' or I am breaking
somewhere else opened door?
The 'trick' I have employed, that I am not sure of, is the redirection to
the AbstractDefaultAjaxBehaviour in the onClick method of the
IndicatingAjaxLink.

2) The problem with this code is that, when I click the download link the
second time the indicator is not revolving. It is being displayed correctly,
and hidden on time, and the CSV data is exported correctly. The problem is
that the indicator is not moving.

Thank you for you assitance in advance,
Robert Szmurlo

Java:

public class HomePage extends WebPage {

private AbstractDefaultAjaxBehavior b;
private String data = null;

public HomePage(final PageParameters parameters) {

final ByteArrayResource bar = new ByteArrayResource(text/csv) {
@Override
public byte[] getData(Attributes attributes) {
byte[] bytes = null;
try {
bytes = data.getBytes();
} catch (Exception e) {
e.printStackTrace();
}
return bytes;
}

@Override
protected void configureResponse(ResourceResponse
response,Attributes attributes) {
super.configureResponse(response, attributes);
response.setFileName(report.csv);
}

};

add( b = new AbstractDefaultAjaxBehavior() {
@Override
protected void respond(AjaxRequestTarget target) {
getRequestCycle().scheduleRequestHandlerAfterCurrent(new
ResourceRequestHandler(bar, getPageParameters()));
}
});

add( new IndicatingAjaxLinkVoid(link) {
@Override
public void onClick(AjaxRequestTarget target) {

prepareData(); // takes some time

if (target != null) {
*target.appendJavaScript(window.location=' + b.getCallbackUrl() + ');*
}
}
});
}

protected void prepareData() {
// JUST FOR TEST
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
/

// atach data?
data = No.;Name\n +
   1.;John\n +
   2.;Mary;
}
}


HTML:
html
body
a wicket:id=linkExport CSV/a
/body
/html







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



Re: reload model each time

2012-04-14 Thread Robert Szmurlo

W dniu 2012-04-14 13:38, Tom Eugelink pisze:


Another newbie question; it is now the case that each model is serialized 
between requests and (I presume) stored in the session. I would really prefer 
if a identifier (primary key + lazy locking versionnr) could be remembered and 
that each time when Wicket needs the model, it is loaded from the database.

AFAIK by default Wicket serializes pages and its attributes to a filestore on a 
disk in a servlet container and the session is not affected. So you don't have 
to worry about its size. But, of course for large objects and specially list 
you should use LoadableDetachableModels.


Is this possible? Is there something like a ReloadingModel?

See section Detachable Models and specially LoadableDetachableModel in 
https://cwiki.apache.org/WICKET/working-with-wicket-models.html


Robert

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



Re: Constructors take vararg of Component? (Enhancement RFC)

2013-01-06 Thread Robert Szmurlo

Hi,

you can use something like this:

RsvpPage.this.add(
new Label(event.title),
new CssFeedbackPanel(feedback),
new FormRsvpPage(frmRsvp, cpm).add(pnlNoRsvp, pnlRsvp, pnlConfirm),
pnlRsvpRules
);

I am not dev, but I wouldn't break the API.

BR,
Robert Szmurlo

W dniu 2013-01-06 20:24, Zac Bedell pisze:

Greetings all,

I was wondering what Wicket users  devs might thing of a possible API change 
for a future version (maybe Wicket 7?) of including a varargs array of Component as 
the final parameter of all of the various MarkupContainer subclasses?  I find 
myself doing things like these a lot:

 pnlNoRsvp = new WebMarkupContainer(pnlNoRsvp);
 pnlRsvp = new StatusPanel(pnlRsvp);
 pnlConfirm = new ConfirmPanel(pnlConfirm);
 pnlRsvpRules = new RsvpRulesPanel(pnlRsvpRules);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm) {
   {
 add(pnlNoRsvp, pnlRsvp, pnlConfirm);
   }
 },
 pnlRsvpRules
 );

-- or --
 
 FormRsvpPage frmRsvp = new FormRsvpPage(frmRsvp, cpm);

 frmRsvp.add(pnlNoRsvp, pnlRsvp, pnlConfirm);

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 frmRsvp,
 pnlRsvpRules
 );

--

If Form and the various other Wicket MarkupContainer's had constructors with 
Component... as their final parameter, it would be possible to do something 
like:

 RsvpPage.this.add(
 new Label(event.title),
 new CssFeedbackPanel(feedback),
 new FormRsvpPage(frmRsvp, cpm, pnlNoRsvp, pnlRsvp, pnlConfirm),
 pnlRsvpRules
 );

--

Granted, this would balloon the number of constructors throughout the framework 
just to save a bit of typing.  Curious what others might think...

Best regards,
Zac Bedell
-
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: Table borders in dataview/listview

2014-07-22 Thread Robert Szmurlo

Hi,

maybe this is an issue related to displaying a zoomed in page in your browser.
Try to reset zoom in your browser to 100% and it should look ok.
From my experience it is a common problem in Firefox.

R.Szmurlo


W dniu 2014-07-22 15:52, K pisze:

Hey

i have been getting a thick borders in my table at a reguler intervals when
i am using listview or dataveiw.
I donno if this is an issue related to wicket, still

Here is a image
http://apache-wicket.1842946.n4.nabble.com/file/n4666732/Capturex.png

Thanks in Advance

-
K
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Table-borders-in-dataview-listview-tp4666732.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