You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2010/06/17 17:22:42 UTC

Specific user/session properties and resources

I still want to use wicket message resource tags in my markup.  But, I
need a system to load and reload resources property data for each page
and request.
Or maybe load properties per user session.  Is this possible using
Wicket resource loader classes.
 
Ideally, it looks like I should use a collection of labels, but I have
code to use the wicket message tags.  Can I have wicket messages
reloaded at each page/request?
 
This is what I am doing now, loading a property file on startup/init.
But
---------
 
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;
import java.util.Locale;
import java.util.Properties;
 
import org.apache.wicket.Component;
import org.apache.wicket.resource.loader.IStringResourceLoader;
 

public class MyResourceLoader implements IStringResourceLoader {
 
 private Properties properties = new Properties();
 
 public void loadProperties() {
  
  final BufferedInputStream bis = new BufferedInputStream(new
ByteArrayInputStream(DevelopmentResources.XML_PROPS.getBytes()));
  try {
   properties.loadFromXML(bis);
  } catch (Exception e) {
   e.printStackTrace();   
  } finally {
   try {
    bis.close();
   } catch (IOException e) {
   }
  } // End of try finally //
 }
 
...
...
 
}
 
Berlin Brown

Re: Specific user/session properties and resources

Posted by Igor Vaynberg <ig...@gmail.com>.
scanning for i18n resources is expensive, that is why they are cached.
if you want something more dynamic perhaps you should not use wicket's
i18n mechanism to accomplish it.

-igor

On Thu, Jun 17, 2010 at 8:22 AM, Brown, Berlin [GCG-PFS]
<Be...@primerica.com> wrote:
> I still want to use wicket message resource tags in my markup.  But, I
> need a system to load and reload resources property data for each page
> and request.
> Or maybe load properties per user session.  Is this possible using
> Wicket resource loader classes.
>
> Ideally, it looks like I should use a collection of labels, but I have
> code to use the wicket message tags.  Can I have wicket messages
> reloaded at each page/request?
>
> This is what I am doing now, loading a property file on startup/init.
> But
> ---------
>
> import java.io.BufferedInputStream;
> import java.io.ByteArrayInputStream;
> import java.io.IOException;
> import java.util.InvalidPropertiesFormatException;
> import java.util.Locale;
> import java.util.Properties;
>
> import org.apache.wicket.Component;
> import org.apache.wicket.resource.loader.IStringResourceLoader;
>
>
> public class MyResourceLoader implements IStringResourceLoader {
>
>  private Properties properties = new Properties();
>
>  public void loadProperties() {
>
>  final BufferedInputStream bis = new BufferedInputStream(new
> ByteArrayInputStream(DevelopmentResources.XML_PROPS.getBytes()));
>  try {
>   properties.loadFromXML(bis);
>  } catch (Exception e) {
>   e.printStackTrace();
>  } finally {
>   try {
>    bis.close();
>   } catch (IOException e) {
>   }
>  } // End of try finally //
>  }
>
> ...
> ...
>
> }
>
> Berlin Brown
>

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