Re: url problem of resourceLink popup page

2012-12-13 Thread Martin Grigorov
Hi,

The popup settings' name is the JavaScript name used in window.open(). It
is used for inter window communication (JavaScript).
The resource name and cache are controlled by IResource's ResourceResponse
fields.


On Wed, Dec 12, 2012 at 7:30 PM, appwicket wwx@gmail.com wrote:

 Hi
 I am using resourceLink for a grammatically generated pdf resource:
 PopupSettings popupSettings = new PopupSettings(resourcePage,
 PopupSettings.RESIZABLE
 |
 PopupSettings.SCROLLBARS).setHeight(500).setWidth(700);
 ResourceLink resourceLink = (ResourceLink) new
 ResourceLink(resourceLink,getMyResource());
 resourceLink.setPopupSettings(popupSettings);
 myForm.add(resourceLink);

 when the popup window opens the name is Page(application/pdf object)
 instead of resourcePage,
 and the link is

 http://localhost:8080/myCompany/previewPDf?3-IResourceListener-myForm-resourceLink

 The resource is generated when user comes to this page by using page
 parameters sent from previous page.

 I notice there are few ways to mount url in application.java but how can I
 mount this dynamic resource?
 another question, sometimes when I open the popup from resourceLink, the
 contents (pdf) are not updating. is there any cache in resourceLink?

 Thanks






 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/url-problem-of-resourceLink-popup-page-tp4654750.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




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com http://jweekend.com/


url problem of resourceLink popup page

2012-12-12 Thread appwicket
Hi 
I am using resourceLink for a grammatically generated pdf resource:
PopupSettings popupSettings = new PopupSettings(resourcePage,
PopupSettings.RESIZABLE
| 
PopupSettings.SCROLLBARS).setHeight(500).setWidth(700);
ResourceLink resourceLink = (ResourceLink) new
ResourceLink(resourceLink,getMyResource());
resourceLink.setPopupSettings(popupSettings);
myForm.add(resourceLink);

when the popup window opens the name is Page(application/pdf object)
instead of resourcePage, 
and the link is
http://localhost:8080/myCompany/previewPDf?3-IResourceListener-myForm-resourceLink

The resource is generated when user comes to this page by using page
parameters sent from previous page.

I notice there are few ways to mount url in application.java but how can I
mount this dynamic resource?
another question, sometimes when I open the popup from resourceLink, the
contents (pdf) are not updating. is there any cache in resourceLink?

Thanks






--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/url-problem-of-resourceLink-popup-page-tp4654750.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



problem with ResourceLink

2009-09-08 Thread Eyal Golan
Hi,
We have the following code:

static public ResourceLink getResourceLink(String id,byte[] data,final
String title,String contentType){
ResourceLink resourceLink = new ResourceLink(id, new
CustomResource(data,contentType,title)){
private static final long serialVersionUID = 1L;

@Override
protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
replaceComponentTagBody(markupStream, openTag, title);
}
};
//resourceLink.add(new Label(title,new Model(title)));
return resourceLink;
}

and CustomResource is:
public class CustomResource extends Resource{

String filename = ;
ByteArrayResource byteArrayResource = null;


public CustomResource (byte[] data,String contentType,String
filename){
byteArrayResource = new
ByteArrayResource(contentType,data,filename);
this.filename = filename;
}

public IResourceStream getResourceStream() {
return byteArrayResource.getResourceStream();
//return getFile();
//return getAttachment();
}

   }

when the user presses a link of a file named: myFile.doc a save dialog is
opened and the file name is ui.doc
I looked into the code and found that in Resource#onResourceRequested
there's the line: cycle.setRequestTarget(new
ResourceStreamRequestTarget(resourceStream));
When I debugged and changed the value of fileName in
ResourceStreamRequestTarget to bla.doc I got the bla.doc in the save dialog.
We use Wicket 1.3.6

How can I call the constructor of ResourceStreamRequestTarget with the file
name?

Another question,
Is there a way to get the content type out of the file without hard coding?
now we have this:
private String getContentType(String fileName){
fileName = fileName.toLowerCase();
String contentType = null;
if (fileName.endsWith(.doc)) {
contentType = application/msword;
} else if (fileName.endsWith(.html)
|| fileName.endsWith(.txt)
|| fileName.endsWith(.log)
|| fileName.endsWith(.properties))
{
contentType = text/html;
} else if (fileName.endsWith(.pdf)) {
contentType = application/pdf;
} else if (fileName.endsWith(.xls)) {
contentType = application/vnd.ms-excel;
} else if (fileName.endsWith(.pot)
|| fileName.endsWith(.pps)
|| fileName.endsWith(.ppt)) {
contentType = application/vnd.ms-powerpoint;
} else if (fileName.endsWith(.zip)) {
contentType = application/x-zip-compressed;
} else if (fileName.endsWith(.jpg)) {
contentType = image/jpeg;
} else if (fileName.endsWith(.png)) {
contentType = image/png;
} else if (fileName.endsWith(.gif)) {
contentType = image/gif;
} else if (fileName.endsWith(.mp3)) {
contentType = audio/mpeg;
} else if (fileName.endsWith(.bmp)) {
contentType = image/bmp;
} else {
//try {
//contentType
=text/+fileName.substring(fileName.lastIndexOf(.)+1);
//} catch (Exception e) {
//}
}
return contentType;
}


BTW,
I've noticed that there's DownloadLink. Should we use this?

Thanks

Eyal Golan
egola...@gmail.com

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary