managed-bean

JSF page redirecting from java bean

拜拜、爱过 提交于 2019-11-28 20:52:02
问题 Is there some way how to redirect page to other page from Java method? I'm able only to forward it using: FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml"); or using navigation-rules of faces-config.xml . Do you have any ideas? 回答1: Not sure what you're after, but the ExternalContext#dispatch() does only a forward, not a redirect. You'd like to use ExternalContext#redirect() instead. externalContext.redirect("foo.xhtml"); or even external (which is not possible

How does JSF find beans annotated with @ManagedBean?

五迷三道 提交于 2019-11-28 18:49:09
As far as I know, for using @Annotations (or [Attributes] in C#) you have to have a reference to the class metadata, so that you can ask if the class is annotated (attributed) or not. My question is how does JSF implementation find all classes annotated with @ManagedBean? Does it scan all of the classes in the class path? Or is there a way to actually "query" the JVM for the annotated classes? I'm asking this because when I put my annotated backing beans in my web project directly, there's no problem. But the beans that I define in the JAR files (to be reusable across projects) are not

ManagedProperty not injected in @FacesConverter

杀马特。学长 韩版系。学妹 提交于 2019-11-28 18:27:38
I'm trying to inject a ManagedBean in my FacesConverted the following way: @ManagedBean @RequestScoped @FacesConverter(forClass = Group.class) public class GroupConverter implements Converter { @ManagedProperty("#{groupService}") private GroupService groupService; @Override public Group getAsObject(FacesContext context, UIComponent arg1, String groupName) { return groupService.findGroupByName(groupName); } @Override public String getAsString(FacesContext arg0, UIComponent arg1, Object group) { return ((Group) group).getName(); } public GroupService getGroupService() { return groupService; }

How to get managedbean property from another bean in JSF

放肆的年华 提交于 2019-11-28 17:58:06
I searched similar questions but I'm a bit confused. I have a login page, so LoginBean also which is; @ManagedBean(name = "loginBean") @SessionScoped public class LoginBean implements Serializable { private String password=""; private String image=""; @ManagedProperty(value = "#{loginBeanIdentityNr}") private String identityNr=""; ... after success, navigates to orderlist page, so I have also OrderBean. @ManagedBean(name = "OrderBean") @SessionScoped public class OrderBean { List<Ordery> sdList; public List<Order> getSdList() { try { String identityNr =""; ELContext elContext = FacesContext

Using f:selectItems var in passtrough attribute

你离开我真会死。 提交于 2019-11-28 13:37:03
can I pass expressions to JSF 2 passthrough-attributes? the following code is not working. expression #{country.isoCode} is not evaluated. <h:selectOneMenu value="#{bean.selectedCountry}" styleClass="selectlist"> <f:selectItems value="#{bean.countries}" var="country" itemLabel="#{country.countryName}" pt:data-icon="flag flag-#{country.isoCode}"/> </h:selectOneMenu> I am using namespace xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" and bootstrap-select. attribute "data-icon" is used to show an image. see: http://silviomoreto.github.io/bootstrap-select/#data-icon rendered output: <i class=

@ManagedProperty injected AFTER @PostConstruct

浪尽此生 提交于 2019-11-28 12:54:19
问题 THIS PROBLEM IS ALREADY SOLVED IN THE MYFACES 2.1 IMPLEMENTATION I have a link which passes an Integer parameter properly like this: <h:link outcome="/process/createProcess"> <f:param name="id" value="#{process.idprocess}" /> Edit </h:link> It goes to "createProcess.xhtml?id=21" properly, and I have this code in the request scope backing Bean createProcess: @ManagedProperty(value="#{param.id}") private Integer idProcess; private Process newProcess; @PostConstruct public void init() { log();

how is the @RequestScoped bean instance provided to @SessionScoped bean in runtime here?

时光毁灭记忆、已成空白 提交于 2019-11-28 12:18:27
I am reading through this example in JBoss where a @RequestScoped bean backing up JSF page is used to pass the user credential information which is then saved in a @sessionScoped bean . Here is the example take from JBoss docs. @Named @RequestScoped public class Credentials { private String username; private String password; @NotNull @Length(min=3, max=25) public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @NotNull @Length(min=6, max=20) public String getPassword() { return password; } public void setPassword(String password)

How to bind List<Integer> values to selectManyListbox in JSF

自闭症网瘾萝莉.ら 提交于 2019-11-28 11:45:05
The situation : I have a JavaServer Faces page and a session-scoped managed bean that has two ArrayList<Integer> properties: one for holding a list of possible values and another for holding a list of selected values. On the JSF page there is a <h:selectManyListBox> component with these two properties bound. The problem : after submitting the form the selected values will be converted to string (the property of type ArrayList actually holds a couple of strings!); however, when I use a converter, I get an error message like this: Validation Error: Value is not valid The question : How can I

Concurrency of @ApplicationScoped JSF managed beans

江枫思渺然 提交于 2019-11-28 11:29:35
I'm using Mojarra 2.2.12 and in our project we've got a few @ApplicationScoped beans. For instance: @ManagedBean @ApplicationScoped public class AppScopedBean{ private int commonValueForClients; //GET, SET public void evalNew(){ int newCommonVal; //Evaluation of the new value, doesn't depend on the commonValueForClients commonValueForClients = newCommonVal; } } My question is should we worry about visibility of the new assigned value? I couldn't find in the spec that JSF infrastructure must synchronize access to @ApplicationScoped bean fields. So, particularly for Mojarra 2.2.12, should we

How to configure a start up managed bean?

£可爱£侵袭症+ 提交于 2019-11-28 11:10:30
I want a managed bean to run internally on start up in my JSF web application when the application loads. How can I write this class and configure in Glassfish? In JSF with CDI, observe the initialization of the application scope . @Named @ApplicationScoped public class App { public void startup(@Observes @Initialized(ApplicationScoped.class) Object context) { // ... } public void shutdown(@Observes @Destroyed(ApplicationScoped.class) Object context) { // ... } } When having OmniFaces at hands, this can be simplified with @Eager . @Named @Eager @ApplicationScoped public class App {