jsf-2

Why my @ApplicationScope CDI bean not updated?

末鹿安然 提交于 2019-12-22 12:54:41
问题 In my application, I have an @ApplicationScoped CDI bean to store some information from the database: @Named @ApplicationScoped public class MrBean { @EJB private SoyaBean soyaBean; private List<Toys> myToys; @PostConstruct public void prepareMrBean() { this.myToys = soyaBean.getToys(); } public void updateToys() { this.myToys = soyaBean.getToys(); } } I also have a AddToy.xhtml page which would simply add a toy to the database. The backing bean is as following: @Named @RequestScoped public

How stop richfaces style?

烈酒焚心 提交于 2019-12-22 11:49:07
问题 I develop this contact form: <!DOCTYPE html> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <h:form> <h:panelGrid columns="3"> <h:outputLabel for="name" value="Nome (Obrigatório)" /> <h:inputText id="name" value="#{contact.client.name}" /> <h:message for="name" /> <h:outputLabel for="email"

Error validating two inputText fields together

旧时模样 提交于 2019-12-22 11:35:45
问题 I have a form with two input fields that have to be validated together . I used this BalusC tutorial as starting point. The requirement is a logical XOR: one of the fields must be filled but not both together . This works fine for all cases except this one: 1) Fill the first field and let the second blank 2) Move to the next page (values get saved) 3) Go back to the first page, delete first field and fill second field . Then I get the error message from my validator ("Do not fill both fields"

JSF 2.0: How to add UIComponents and their contents to view root?

做~自己de王妃 提交于 2019-12-22 11:24:19
问题 I am building a custom UIComponent and adding elements (and other stock UIComponents) inside it. The component renders ok, however it cannot be found from the ViewRoot . Let's say I have: ResponseWriter writer; @Override public void encodeBegin(FacesContext context) throws IOException { writer = context.getResponseWriter(); writer.startElement("div", this); writer.writeText("testing", null); writer.writeAttribute("id", getClientId(context) + ":testDiv", null); } @Override public void

JSF beans and serializability issue

China☆狼群 提交于 2019-12-22 11:16:59
问题 I have problem with JSF beans using Spring managed services. I got an error telling, that spring bean used in JSF bean is not serializable. @ManagedProperty("#{customerService}") private CustomerService customerService; I can't make the service serializable, because it is using JdbcTemplate which itself isn't serializable. Moreover, serializing Spring beans which have application scope makes no sense at all, so I don't understand, why someone's code is attempting to serialize them. I have

JSF beans and serializability issue

拥有回忆 提交于 2019-12-22 11:16:31
问题 I have problem with JSF beans using Spring managed services. I got an error telling, that spring bean used in JSF bean is not serializable. @ManagedProperty("#{customerService}") private CustomerService customerService; I can't make the service serializable, because it is using JdbcTemplate which itself isn't serializable. Moreover, serializing Spring beans which have application scope makes no sense at all, so I don't understand, why someone's code is attempting to serialize them. I have

JSF2.0 Passing Value objects between managed beans

倾然丶 夕夏残阳落幕 提交于 2019-12-22 11:15:32
问题 I've already written a small JSF2.0 app utilising Weblogic 10.3.4, PrimeFaces and JQuery. I'm now looking at converting our Main Web App to JSF2.0. This is currently uses Weblogic 8.1, Java 1.4 and JSP's. The question I have at the moment is what is best way to pass objects from one managed bean to another. Our app consists of many screens but the general pattern is a reference is entered on the first screen and on submit this is looked up from the Database and a Value Object is populated

How to use both Navigation Rule and f:ajax

强颜欢笑 提交于 2019-12-22 11:01:41
问题 Here's my scenario: I'd like to update a page via Ajax in some cases, in other cases, execute a navigation rule. My use case is a login form. I'd like them to receive an error message via ajax if their uname/password fails, but navigate to a new page if it succeeds. Has anyone done this using JSF2.0 f:ajax apis? I'm not really interested in solutions that go outside standard facelets, jsf2.0, etc. 回答1: It's not different from when doing it without ajax. Just return the next view ID as String

How to validate a date from a Calendar

空扰寡人 提交于 2019-12-22 10:57:08
问题 I have tried the following code (I have followed an example) to test a date choosen from a calendar. If the date don't exist in my database, then a validation error message should be shown to the enduser. However, the error does not end up in the <h:message> , instead it is being logged to the server log. View: <p:calendar id="date1" value="#{bean.date1}" showOn="button"> <f:validator validatorId="calendarValidator" /> <f:ajax execute="date1" render="calendarmessage" /> </p:calendar> <h

JSF2 and PrettyFaces… how does one get the original URL or the query string?

人盡茶涼 提交于 2019-12-22 10:55:40
问题 PrettyFaces is a dead simple URL rewriting engine. All sorts of SEO is possible and it is really really easy . I have one small problem though :( Using pretty faces, I have this rewrite rule: <url-mapping id="blogEntry"> <pattern value="/blog/#{shortUrl}" /> <view-id value="/blogEntry.jsf" /> </url-mapping> So the URL bar looks like: http://host.com/blog/first-post And the rewrite rule maps the request internally to: http://host.com/blogEntry?shortUrl=first-post I'm implementing OpenID, which