[JBoss Seam] - Re: ResourceBundle in Database
by Zerg-Spirit
Ok, then I must do something wrong, that's for sure.
I have overriden 2 classes:
ResourceLoader and MessageFactory
ResourceLoader:
@Scope(SESSION)
| @BypassInterceptors
| @Name("org.jboss.seam.core.resourceLoader")
| public class ExtendedResourceLoader extends
| org.jboss.seam.core.ResourceLoader {
| ...
|
| @Override
| @Observer("org.jboss.seam.localeSelected")
| public ResourceBundle loadBundle(String bundleName) {
|
| try {
| if (DBControl.getInstance().isDirty(
| org.jboss.seam.core.Locale.instance().toString()))
| //If the current locale is dirty, we create a new bundle.
| ResourceBundle bundle = DBControl.getInstance().newBundle(
| bundleName, Locale.instance(), "Db",
| Thread.currentThread().getContextClassLoader(), true);
| return bundle;
| else {
| ResourceBundle bundle = ResourceBundle.getBundle(bundleName,
| Locale.instance(), Thread.currentThread()
| .getContextClassLoader(), DBControl
| .getInstance());
| return bundle;
| }
messageFactory:
@Scope(SESSION)
| @BypassInterceptors
| @Name("org.jboss.seam.international.messagesFactory")
| public class SeamMessages extends Messages {
| @Override
| public Map<String,String> createMap(){
| ResourceBundle resourceBundle = org.jboss.seam.core.ResourceBundle.instance();
| //That retrived bundle doesn't match the newly created bundle in ResourceLoader overriden class, so the created map isn't matching the current state of the database.
|
| ...
| public static Map<String, String> instance()
| {
|
| if ( !Contexts.isSessionContextActive() )
| {
| throw new IllegalStateException("no event context active");
| }
|
| return (Map<String, String>) Component.getInstance("org.jboss.seam.international.messages", true);
| }
DBcontrol is a custom class extending Control class to instanciate ResourceBundles that are loading data from the database (this mecanism works since when the app is deployed, the correct messages are loaded, as well as when I'm changing the locale).
So basically, when I changed a message and reload the locale, the change isn't performed on messages map.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4082045#4082045
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4082045
18 years, 7 months
[JBoss Seam] - Facotry-session and bean-conversation
by yohann49
Hello !
I was wondering if it could be possible to have a bean wich his scope is CONVERSATION and a fctory in this bean whis his scope is SESSION. I want to do that but when I want to go to the xhtml page, I have this exception :
Exception during request processing: javax.servlet.ServletException: factory method with defined scope outjected a value: orders
My bean :
|
| @Stateful
| @Name("ListOrder")
| @Scope(CONVERSATION)
| public class OrderManager implements OrderManagerLocal, Serializable {
|
| @DataModel("orders") List<Order> orders;
|
| @Factory(value="orders", scope = SESSION)
| public void findOrder(){
|
| Query query;
|
| query = em.createQuery("select o from Order o where o.customer=#{currentContact.customer}");
|
|
| orders = (List<Order>) query.getResultList();
|
|
| }
| }
|
Thanks Yohann
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4082041#4082041
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4082041
18 years, 7 months