PackageResource

2013-11-18 Thread MartinoSuperman
Hi

For my website, I am using a ResourceReference, in which a PNG file is
loaded to show it on the web page.

The PNG picture shown well, but when I change that PNG picture by redrawing
it in Java with the help of Graphics2D, you still see the former PNG picture
on the web page, whereas the newest PNG picture is drawn behind the scenes.
That redrawing works fine.

What I want, is the following:

Each time, when the PNG picture is redrawn that new PNG picture must be
shown on the web page, immediately after that, when you refreshes the page.
Now, you only get that new PNG picture, when you close your browser and
reopens it and goed to the webpage again.

Does someone know how to 'refresh' that newly redrawn PNG picture in the
webpage?





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PackageResource-tp4662486.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: PackageResource

2013-11-18 Thread Martin Grigorov
Hi,

It is a caching problem.
Use NonCachingImage component instead of Image.


On Mon, Nov 18, 2013 at 11:19 AM, MartinoSuperman
martinosuper...@live.nlwrote:

 Hi

 For my website, I am using a ResourceReference, in which a PNG file is
 loaded to show it on the web page.

 The PNG picture shown well, but when I change that PNG picture by redrawing
 it in Java with the help of Graphics2D, you still see the former PNG
 picture
 on the web page, whereas the newest PNG picture is drawn behind the scenes.
 That redrawing works fine.

 What I want, is the following:

 Each time, when the PNG picture is redrawn that new PNG picture must be
 shown on the web page, immediately after that, when you refreshes the page.
 Now, you only get that new PNG picture, when you close your browser and
 reopens it and goed to the webpage again.

 Does someone know how to 'refresh' that newly redrawn PNG picture in the
 webpage?





 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/PackageResource-tp4662486.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




PackageResource changes in 1.5

2011-09-09 Thread Ian Marshall
Hello there,

I know that this is not an ideal time (Friday afternoon and all that), but I
have a problem migrating from 1.4.18 to 1.5.0.

I have a business class which reads properties from its .xml properties
file. I used org.apache.wicket.markup.html.PackageResource to start doing
this, but I find that this class is now in a different package
(org.apache.wicket.request.resource.PackageResource) without the methods
that I use.

Does anyone know a good way to read an .xml properties file in 1.5? (I set
out a code summary followed by a fuller code extract below.)

Any help would be much appreciated,

Ian




1.4.8 code summary
--
  import org.apache.wicket.markup.html.PackageResource;
  import org.apache.wicket.request.resource.PackageResource;

  ...

  Properties propProperties = new Properties();
  boolean bLoadSuccess = false;

 
/
  // This code will not compile
  //
  PackageResource prResource =
   PackageResource.get(MyClass.class, MyClass.class.getSimpleName() +
.xml);

  IResourceStream rsStream = prResource.getResourceStream();
  //
 
/
  try
  {
try
{
  InputStream isStream = rsStream.getInputStream();
  propProperties.loadFromXML(isStream);
  bLoadSuccess = true;
}
catch (...)
{
  ...
  }
  finally
  {
try
{
  rsStream.close();
}
...
  }




1.4.8 fuller code extract
-
import org.apache.wicket.markup.html.PackageResource;
import org.apache.wicket.request.resource.PackageResource;

public class MailBusiness
{
  ...

  private static final Logger g_logger =
   Logger.getLogger(MailBusiness.class.getName());

  // The .properties extension for package resources gets blocked
  // by the Wicket framework by default, so use something else.
  private static final String G_S_PROPERTIES_FILE_NAME =
   MailBusiness.class.getSimpleName() + .xml;

  private static String G_S_ADDRESS_FROM = ;
  private static boolean g_bPropertiesLoaded = false;

  ...

  /**
   * Load the properties from this class's related properties file.
   * @return
   *   codetrue/code if the properties have been loaded successfully
   *   before or during the call to this method, otherwise
codefalse/code.
   */
  private static boolean loadProperties()
  {
if (!g_bPropertiesLoaded)
{
  Properties propProperties = new Properties();
  boolean bLoadSuccess = false;
  PackageResource prResource =
   PackageResource.get(MailBusiness.class, G_S_PROPERTIES_FILE_NAME);

  IResourceStream rsStream = prResource.getResourceStream();
  try
  {
try
{
  InputStream isStream = rsStream.getInputStream();
  propProperties.loadFromXML(isStream);
  bLoadSuccess = true;
}
catch (ResourceStreamNotFoundException e)
{
  g_logger.log(Level.SEVERE, null, e);
}
catch (IOException e)
{
  g_logger.log(Level.SEVERE, null, e);
}
  }
  finally
  {
try
{
  rsStream.close();
}
catch (IOException e)
{
  g_logger.log(Level.SEVERE, null, e);
}
  }

  if (bLoadSuccess)
  {
G_S_ADDRESS_FROM = propProperties.getProperty(G_S_KEY_ADDRESS_FROM,
);

...

g_bPropertiesLoaded = true;
  }
}

return g_bPropertiesLoaded;
  }

  ...
}

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PackageResource-changes-in-1-5-tp3801683p3801683.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



PackageResource changes in 1.5

2011-09-09 Thread Ian Marshall
I have now coded:

  import org.apache.wicket.request.resource.PackageResource;
  import org.apache.wicket.request.resource.PackageResourceReference;

  PackageResourceReference prrResource = new PackageResourceReference(
   MailBusiness.class, MailBusiness.class.getSimpleName() + .xml);
  PackageResource prResource = (PackageResource)prrResource.getResource();

  IResourceStream rsStream = prResource.getCacheableResourceStream();
  ...
  InputStream isStream = rsStream.getInputStream();
  propProperties.loadFromXML(isStream);
  ...

I have not run this yet (I cannot build since I am still fettling my 1.4.18
into 1.5.0) but does anyone know whether am I on the right lines or not?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PackageResource-changes-in-1-5-tp3801683p3801827.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: PackageResource changes in 1.5

2011-09-09 Thread Igor Vaynberg
InputStream 
in=MailBusiness.class.getResource(MailBusiness.class.getSimpleName()+.xml);

no need to use wicket at all

-igor

On Fri, Sep 9, 2011 at 7:23 AM, Ian Marshall ianmarshall...@gmail.com wrote:
 I have now coded:

  import org.apache.wicket.request.resource.PackageResource;
  import org.apache.wicket.request.resource.PackageResourceReference;

  PackageResourceReference prrResource = new PackageResourceReference(
   MailBusiness.class, MailBusiness.class.getSimpleName() + .xml);
  PackageResource prResource = (PackageResource)prrResource.getResource();

  IResourceStream rsStream = prResource.getCacheableResourceStream();
  ...
  InputStream isStream = rsStream.getInputStream();
  propProperties.loadFromXML(isStream);
  ...

 I have not run this yet (I cannot build since I am still fettling my 1.4.18
 into 1.5.0) but does anyone know whether am I on the right lines or not?

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/PackageResource-changes-in-1-5-tp3801683p3801827.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



Re: PackageResource changes in 1.5

2011-09-09 Thread Ian Marshall
Thanks for the tip, Igor.

I have coded with

  MailBusiness.class.getResourceAsStream(...)

and I shall verify this after I fettle my app for building.

Ian



Igor Vaynberg-2 wrote:
 
 InputStream
 in=MailBusiness.class.getResource(MailBusiness.class.getSimpleName()+.xml);
 
 no need to use wicket at all
 
 -igor
 
 On Fri, Sep 9, 2011 at 7:23 AM, Ian Marshall
 lt;ianmarshall...@gmail.comgt; wrote:
 I have now coded:

  import org.apache.wicket.request.resource.PackageResource;
  import org.apache.wicket.request.resource.PackageResourceReference;

  PackageResourceReference prrResource = new PackageResourceReference(
   MailBusiness.class, MailBusiness.class.getSimpleName() + .xml);
  PackageResource prResource = (PackageResource)prrResource.getResource();

  IResourceStream rsStream = prResource.getCacheableResourceStream();
  ...
  InputStream isStream = rsStream.getInputStream();
  propProperties.loadFromXML(isStream);
  ...

 I have not run this yet (I cannot build since I am still fettling my
 1.4.18
 into 1.5.0) but does anyone know whether am I on the right lines or not?

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/PackageResource-changes-in-1-5-tp3801683p3801827.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
 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/PackageResource-changes-in-1-5-tp3801683p3802148.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: Using IResourceCachingStrategy with context relative resources(non PackageResource)

2011-08-02 Thread Pedro Santos
Yes, it is there for package resources. Better would be write a
javax.servlet.Filter with the described logic.

On Tue, Aug 2, 2011 at 11:46 AM, Serban.Balamaci thespamtr...@gmail.com wrote:
 Hello all,
 I'm using Wicket 1.5RC5.1.

 It seems that IResourceCachingStrategy can only be used on
 PackageResource(in BasicResourceReferenceMapper
 getCachingStrategy().decorateUrl() if reference instanceof
 PackageResourceReference), is that right?

 Could I obtain the benefits for resources that are under /webapp/js,
 /webapp/css?

 Because I want to use wro4j to compact js and css files and  write under js
 and css at /webapp/wro, but also have the benefits of
 FilenameWithVersionResourceCachingStrategy, so everytime the application is
 redeployed I want the users to receive the new compacted .js and .css files.

 Is there another approach?

 Thanks.

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Using-IResourceCachingStrategy-with-context-relative-resources-non-PackageResource-tp3712574p3712574.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





-- 
Pedro Henrique Oliveira dos Santos

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



Re: Using IResourceCachingStrategy with context relative resources(non PackageResource)

2011-08-02 Thread Alex Objelean
Serban, if you are using wro4j-maven-plugin, you can achieve the
FilenameWithVersionResourceCachingStrategy feature by providing the 
http://code.google.com/p/wro4j/wiki/OutputNamingStrategy Resource Naming
Strategy .

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-IResourceCachingStrategy-with-context-relative-resources-non-PackageResource-tp3712574p3713308.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: Using IResourceCachingStrategy with context relative resources(non PackageResource)

2011-08-02 Thread Serban.Balamaci
Merci Alex,
I indeed use the maven plugin and didn't consider a NamingStrategy, but at
first look we would not be able to reference back the generated file in
Wicket, right?

But I think that context resources not only PackageResources should be
candidates for a ResourceCachingStrategy and not need a special filter to
handle this.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-IResourceCachingStrategy-with-context-relative-resources-non-PackageResource-tp3712574p3713469.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: Using IResourceCachingStrategy with context relative resources(non PackageResource)

2011-08-02 Thread Alex Objelean
It should be possible to include dynamically all resources in the page
contained inside a servlet context folder (no need to know the exact name of
the resource).

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Using-IResourceCachingStrategy-with-context-relative-resources-non-PackageResource-tp3712574p3713807.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: PackageResource that isn't tied to session; returns 302?

2010-04-15 Thread Nikita Tovstoles
Answering my own question: use Resource Reference:

new Image(img, new ResourceReference(Page2.class, image.png));



On Wed, Apr 14, 2010 at 3:23 PM, Nikita Tovstoles 
nikita.tovsto...@gmail.com wrote:

 Correction:
 PackageResource packageResource = PackageResource.get(Page2.class,
 image.png);

 does correctly set response headers (to allow for 304). But, for some
 reason, the link generated is not static and is instead tied to an
 HttpSession. Any way to get a Session-independent packageResource (for
 static image)?

 On Tue, Apr 13, 2010 at 6:05 PM, Nikita Tovstoles 
 nikita.tovsto...@gmail.com wrote:

 Given this page:
 public class Page2 extends WebPage {

 public Page2() {

  add(new Image(plainImage, image.png));
  PackageResource packageResource = PackageResource.get(Page2.class,
 image.png);
  add(new Image(pkgImage, packageResource));
 }
 }

 plainImage produces an img that returns a 304 on page reload; and is not
 tied to a session.

 pkgImage, however, renders as a 'wicket:interface' url that actually
 re-loads an image (200) on page reload, and is tied to a session (throws
 PageExpiredException) when session expires or sessionid is removed from img
 src.

 Is there way to get a (Package)Resource that is not session-specific? I
 see a SharedResources but am unsure how to access it. We need to new Image
 in several places whose source paths are computed at render time from page
 params, yet are always relative to the same component class (support of
 multiple LF).

 I recognize that we could use a ContextImage instead, but I am curious to
 find an approach that would also work for JS/CSS.

 thanks
 -nikita







-- 
---
Nikita Tovstoles
CTO, CastaneaLabs.com
(m) +1-650-996-8173
(e) ntovsto...@castanealabs.com
---


PackageResource that isn't tied to session; returns 302?

2010-04-13 Thread Nikita Tovstoles
Given this page:
public class Page2 extends WebPage {

public Page2() {

 add(new Image(plainImage, image.png));
 PackageResource packageResource = PackageResource.get(Page2.class,
image.png);
add(new Image(pkgImage, packageResource));
}
}

plainImage produces an img that returns a 304 on page reload; and is not
tied to a session.

pkgImage, however, renders as a 'wicket:interface' url that actually
re-loads an image (200) on page reload, and is tied to a session (throws
PageExpiredException) when session expires or sessionid is removed from img
src.

Is there way to get a (Package)Resource that is not session-specific? I see
a SharedResources but am unsure how to access it. We need to new Image in
several places whose source paths are computed at render time from page
params, yet are always relative to the same component class (support of
multiple LF).

I recognize that we could use a ContextImage instead, but I am curious to
find an approach that would also work for JS/CSS.

thanks
-nikita


Re: PackageResource - why does'nt get Locale directly from Session ?

2008-06-09 Thread Stefan Simik

Oh yes :-) 
I think, that taking Locale from session could be the most used = the most
suitable default strategy.
Session is the most used place for storing Locale.
I think, that preferred way should be getting Locale from Session as
default.
Passing Locale parameter to the PackageResource constructor does'nt seem to
me like a better way.
Who wants, can subclass PackageResource and override in you own specific
way.
What do you think about it ? 

Stefan




That's just by design to not make the assumption where the locale
comes from. But you can override the class and pass
Session.get().getLocale() and you're done :-)

Eelco

-- 
View this message in context: 
http://www.nabble.com/PackageResource---why-does%27nt-get-Locale-directly-from-Session---tp17696134p17730001.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: PackageResource - why does'nt get Locale directly from Session ?

2008-06-09 Thread Eelco Hillenius
We'd have to have a good reason the break the API. And it's just
something you'd prefer to be different, but it doesn't give you
troubles you can't get around, right? :-)

Eelco

On Mon, Jun 9, 2008 at 3:21 AM, Stefan Simik [EMAIL PROTECTED] wrote:

 Oh yes :-)
 I think, that taking Locale from session could be the most used = the most
 suitable default strategy.
 Session is the most used place for storing Locale.
 I think, that preferred way should be getting Locale from Session as
 default.
 Passing Locale parameter to the PackageResource constructor does'nt seem to
 me like a better way.
 Who wants, can subclass PackageResource and override in you own specific
 way.
 What do you think about it ?

 Stefan




 That's just by design to not make the assumption where the locale
 comes from. But you can override the class and pass
 Session.get().getLocale() and you're done :-)

 Eelco

 --
 View this message in context: 
 http://www.nabble.com/PackageResource---why-does%27nt-get-Locale-directly-from-Session---tp17696134p17730001.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: PackageResource - why does'nt get Locale directly from Session ?

2008-06-09 Thread Stefan Simik

yes, sure :)
It's OK, it is really my preference only ;)



Eelco Hillenius wrote:
 
 We'd have to have a good reason the break the API. And it's just
 something you'd prefer to be different, but it doesn't give you
 troubles you can't get around, right? :-)
 
 Eelco
 
 On Mon, Jun 9, 2008 at 3:21 AM, Stefan Simik [EMAIL PROTECTED]
 wrote:

 Oh yes :-)
 I think, that taking Locale from session could be the most used = the
 most
 suitable default strategy.
 Session is the most used place for storing Locale.
 I think, that preferred way should be getting Locale from Session as
 default.
 Passing Locale parameter to the PackageResource constructor does'nt seem
 to
 me like a better way.
 Who wants, can subclass PackageResource and override in you own specific
 way.
 What do you think about it ?

 Stefan




 That's just by design to not make the assumption where the locale
 comes from. But you can override the class and pass
 Session.get().getLocale() and you're done :-)

 Eelco

 --
 View this message in context:
 http://www.nabble.com/PackageResource---why-does%27nt-get-Locale-directly-from-Session---tp17696134p17730001.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/PackageResource---why-does%27nt-get-Locale-directly-from-Session---tp17696134p17737813.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: PackageResource - why does'nt get Locale directly from Session ?

2008-06-08 Thread Eelco Hillenius
That's just by design to not make the assumption where the locale
comes from. But you can override the class and pass
Session.get().getLocale() and you're done :-)

Eelco

On Fri, Jun 6, 2008 at 9:17 AM, Stefan Simik [EMAIL PROTECTED] wrote:

 Hi boys,

 I would like to ask, why PackageResource doesn't take the Locale
 from the session, but in constructor ?
 It could be comfortable, if no Locale specified in constructor,
 then it could be taken directly from the session.

 Thanx for the answer.
 Stefan Simik
 --
 View this message in context: 
 http://www.nabble.com/PackageResource---why-does%27nt-get-Locale-directly-from-Session---tp17696134p17696134.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



PackageResource - why does'nt get Locale directly from Session ?

2008-06-06 Thread Stefan Simik

Hi boys,

I would like to ask, why PackageResource doesn't take the Locale 
from the session, but in constructor ?
It could be comfortable, if no Locale specified in constructor, 
then it could be taken directly from the session.

Thanx for the answer.
Stefan Simik
-- 
View this message in context: 
http://www.nabble.com/PackageResource---why-does%27nt-get-Locale-directly-from-Session---tp17696134p17696134.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]