6
I am using jsf 2.2. I have 2 @Named
@Named(value = "menuMB")
@ViewScoped
public class MenuMB implements Serializable{
}
@Named(value = "produtoGeralMB")
@ViewScoped
public class ProdutoGeralMB implements Serializable{
@Inject
private MenuMB menuMB;
}
Within the produtoGeralMB
I have a method that changes a property of the menuMB
, however on the jsf page if I use in an inputText #{menuMB.minhaPropriedade}
, after ajax there is no change, if use #{produtoMB.menuMB.minhaPropriedade}
works.
I noticed that the CDI works with proxy for the injected object. There is something to which on the page I use #{menuMB.minhaPropriedade}
and not #{produtoMB.menuMB.minhaPropriedade}
? Why does this happen if there is only one instance of menuMB
in remembrance?
I’m already using javax.faces.view.Viewscoped
– Ricardo Palazzio
Maybe it’s a bug in your implementation (or in the combination of environment components). Try to get the bean directly from context to see if it is properly populated:
context.getApplication().evaluateExpressionGet(context, "#{menuMB}", MenuMB.class);
. Your problem also looks a lot like this one (in English). It may be worth trying to change thejavax.faces.STATE_SAVING_METHOD
forserver
– Anthony Accioly
Finally. If nothing else goes right, shoot Myfaces + CODI (I don’t know what its implementation but I’ve hit similar bugs in Mojarra and I’m quite satisfied with Myfaces).
– Anthony Accioly
javax.faces.STATE_SAVING_METHOD was already on server. I also tried parcial_state_saving false but could not be used with Richfaces4. When I get into the context menuMB is populated. I also believe it is something of the implementation, I am trying to use the latest version of everything, richfaces4 + glassfish4 + jsf 2.2.5. I’m going to do a test with CODI. Thank you for your attention!
– Ricardo Palazzio
Glassfish 4 comes with Mojarra, switch to Myfaces + CODI which is sure it will (I have an application doing something similar in Jetty). At least you have the work-Around now (recover directly from the context).
– Anthony Accioly