2
0
Fork 0

Switch to new meta model,fixed small bugs and made demo work pretty oke.

This commit is contained in:
Willem Cazander 2013-01-11 23:48:36 +01:00
parent afd821c360
commit b3635cf64d
46 changed files with 1055 additions and 688 deletions

View file

@ -0,0 +1,106 @@
/*
* Copyright 2009-2012 forwardfire.net All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.forwardfire.vasc.demo.tech.web.beans;
import java.util.Collection;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import javax.faces.context.FacesContext;
/**
* I18nController wraps to root application bundle to skip jsf cache.
*
* @author Willem Cazander
* @version 1.0 Jan 7, 2013
*/
public class I18nController implements Map<String,String> {
public ResourceBundle getBundle() {
Locale locale = null;
FacesContext context = FacesContext.getCurrentInstance();
locale = context.getApplication().getDefaultLocale();
ResourceBundle bundle = ResourceBundle.getBundle("net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle", locale);
return bundle;
}
@Override
public void clear() {
}
@Override
public boolean containsKey(Object key) {
return getBundle().containsKey((String)key);
}
@Override
public boolean containsValue(Object value) {
return false;
}
@Override
public Set<java.util.Map.Entry<String, String>> entrySet() {
return null;
}
@Override
public String get(Object key) {
return getBundle().getString((String)key);
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public Set<String> keySet() {
return getBundle().keySet();
}
@Override
public String put(String key, String value) {
return value;
}
@Override
public void putAll(Map<? extends String, ? extends String> arg0) {
}
@Override
public String remove(Object key) {
return (String)key;
}
@Override
public int size() {
return getBundle().keySet().size();
}
@Override
public Collection<String> values() {
return null;
}
}

View file

@ -7,10 +7,12 @@
>
<application>
<!-- moved to I18nController because of hard caching resources in jsf impl.
<resource-bundle>
<base-name>net.forwardfire.vasc.lib.i18n.bundle.RootApplicationBundle</base-name>
<var>i18n</var>
</resource-bundle>
-->
<locale-config>
<default-locale>en</default-locale>
</locale-config>
@ -20,6 +22,13 @@
</system-event-listener>
</application>
<managed-bean>
<description>I18n map bean as workaround for jsf caching.</description>
<managed-bean-name>i18n</managed-bean-name>
<managed-bean-class>net.forwardfire.vasc.demo.tech.web.beans.I18nController</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
<description>Fixes the context path for root vs non-root deployments.</description>
<managed-bean-name>contextPathController</managed-bean-name>