facelets

Avoiding duplicate ids when reusing facelets compositions in the same naming container

谁说胖子不能爱 提交于 2019-11-26 17:45:36
I have a <ui:composition> that contains a few elements with explicit ids and some ajax events which reference these ids for partial processing/updating. I encapsulated this fragment of xhtml inside the composition simply so I could use it in a few different places without having to duplicate the code. However, when I use the composition (with <ui:include> ) more than once inside a page, I get duplicate id exceptions. It seems JSF is not wrapping each composition inside its own naming container (like <ui:component> does). Is there a simple way to wrap my composition inside its own naming

Facelets and JSTL (Converting a Date to a String for use in a field)

空扰寡人 提交于 2019-11-26 17:17:18
问题 I need to convert a Date to a String within a page (I dont want to add loads of toStrings to my domain model so adding to the bean is not an option). <ice:graphicImage value="bean.image" title="#{bean.date}"/> The above code works but formats the Date in the default format...I would like to change the format. I have tried using JSTL fmt but this doesnt seem to be compatible with Facelets JSF Convert dates for title attribute . Is there a workaround for this (doesnt have to use JSTL)? Thanks.

Does it matter whether place f:event inside f:metadata or not?

試著忘記壹切 提交于 2019-11-26 17:03:50
问题 w.r.t. How to execute action on GET request with f:viewParam? <f:metadata> <f:viewParam name="id" value="#{tInputBean.id}" /> <f:event type="preRenderView" listener="#{tInputBean.init}" /> </f:metadata> I'm interested to know whether it matters if a preRenderView f:event is placed inside the f:metadata or not. I've checked the Java EE6 tutorial, Java Server Faces 2.0 Complete Reference, and Core JSF2, and none of them have examples of f:event inside f:metadata, but I've seen lots of examples

JSF tags not rendered [duplicate]

一笑奈何 提交于 2019-11-26 16:48:02
问题 This question already has an answer here : JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output (1 answer) Closed 3 years ago . I am new to JSF, but my JSF tags are not rendered in xhtml file, i tried out every possible solution, but problem is not solved my web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns

Using new xmlns.jcp.org namespace on composites causes java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.putIfAbsent

只愿长相守 提交于 2019-11-26 16:47:09
问题 I am reading The Java EE 7 Tutorial from http://docs.oracle.com/javaee/7/tutorial/doc/jsf-facelets005.htm#GIQZR After I typed the example code in the chapter 8.5 Composite Components in my IDE and run the example on GlassFish4.0, I got an error java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1078) at com.sun.faces.util.Cache.get(Cache.java:116) at com.sun.faces.application.view.FaceletViewHandlingStrategy.getComponentMetadata

Is Facelets page generated to Servlet as JSP generated to Servlet

ぃ、小莉子 提交于 2019-11-26 16:46:40
问题 As all JSPs are generated / translated to Servlets before their execution, is its true for Facelets too? I am working with JSF 2.0 and Facelets and wanted to see its generated Java Code which might be Servlet. 回答1: No, Facelets files are parsed to a XML tree using a SAX parser. The XML tree is stored in the Facelet cache. The XML tree is during view build time turned into an UIComponent tree which is accessible by FacesContext#getViewRoot() (which you can traverse by getChildren() during

how to share a jsf error page between multiple wars

北城以北 提交于 2019-11-26 16:30:11
问题 I'm trying to share an error page (error.xhtml) between multiple wars. They are all in a big ear application, and all use a common jar library, where I'd like to put this. The error page should use web.xml, or better web-fragment.xml, and would be declared as a standard java ee error page. Actual EAR structure: EAR EJB1 EJB2 WAR1 (using CommonWeb.jar) WAR2 (using CommonWeb.jar) WAR3 (using CommonWeb.jar) Just putting the error page under META-INF/resources won't work, as it's not a resource.

JSF and automatic reload of xhtml files

[亡魂溺海] 提交于 2019-11-26 16:13:53
问题 I had some problems with hot-reloading XHTML files using JRebel, Spring, JSF Mojarra 2.0.3 and WebLogic 10.3. JRebel reloads regular Java classes and js/css files under /WebContent successfully, but not JSF's .xhtml files. A full republish was necessary to get xhtml files updated on the server. By trial and error I finally got it to work by adding some facelets parameters to web.xml and creating a custom ResourceResolver as described in this blog post. However, I wonder WHY this works, and

understand the purpose of jsf ui:composition

ぃ、小莉子 提交于 2019-11-26 14:46:40
问题 What is the usefulness of the following? <ui:composition template="template.xhtml">; "In a template client page using <ui:composition> , anything outside of the bounds of a tag is ignored and is not included in the rendered output" (JavaServerFaces 2.0, the complete reference, pg.61) Since everything outside <ui:define> is ignored, why put anything there? Nothing has to be put outside the <ui:define> . But doing so, all I get will be the template itself with only some "variable" parts filled.

How iterate over List<T> and render each item in JSF Facelets

て烟熏妆下的殇ゞ 提交于 2019-11-26 14:44:09
I am wondering how to display a List<T> as obtained below in a Facelet: public List<T> searchByString(String string) { return getEntityManager().createNamedQuery("Userdetails.findByUsername").setParameter("username", "%" + string + "%").getResultList(); } Would a <h:dataTable> be a suitable way? You're going need to iterate over it. JSF 2 offers three iteration components out the box. Provided that the User entity look like below, @Entity public class User { private @Id Long id; private String username; private String email; private LocalDate birthdate; // Add/generate getters+setters. } and