facelets

Get Request and Session Parameters and Attributes from JSF pages

左心房为你撑大大i 提交于 2019-11-26 09:18:24
问题 I\'m using JSF with facelets and I need to get the request and session parameters inside the JSF page. In JSP pages I got this parameter like that: \"${requestScope.paramName}\" or \"${sessionScope.paramName}\" . But now after using JSF there are only beans and you can\'t get any value except bean attributes. NOTE: The session attributes what I need is auto filled using acegi security so I can\'t get any access to them. So what to do now? 回答1: You can get a request parameter id using the

How can I set id of a component/tag inside ui:repeat

荒凉一梦 提交于 2019-11-26 09:03:25
问题 I\'m trying to assign an id to a component inside a <ui:repeat> like that: <ui:repeat value=\"#{bean.columns}\" var=\"column\"> <h:panelGroup layout=\"block\" id=\"column_#{column.id}\" styleClass=\"#{column.id} dashboard_column\"> The thing is that #{column.id} value is being placed properly inside the styleClass value but its not being set inside the id attribute. All that is being set inside the id attribute is the automatically generated id by the JSF + my hard coded value column_ . If I

How to use Facelets composition with files from another context

谁说胖子不能爱 提交于 2019-11-26 08:33:52
问题 I have an application that use composition (for page templates). But we think in create a web-application (war) to host all templates shared by all applications in the same host of all applications. How I can include a template from another context? At this time I use import from http request. But it\'s sounds like bad. <ui:composition template=\"http://localhost:8080/templates/layout/foo.xhtml\"> I\'m using JBoss Seam 2.x with JSF 1. 回答1: Note that this is to be done differently in JSF 2.x

How to invalidate an user session when he logs twice with the same credentials

空扰寡人 提交于 2019-11-26 07:34:28
问题 I\'m using JSF 1.2 with Richfaces and Facelets. I have an application with many session-scoped beans and some application beans. The user logs in with, let\'s say, Firefox. A session is created with ID=\"A\"; Then he opens Chrome and logs in again with the same credentials. A session is created with ID=\"B\". When the session \"B\" is created, I want to be able to destroy session \"A\". How to do that? Also. when the user in Firefox does anything, I want to be able to display a popup or some

How to create a custom Facelets tag?

爱⌒轻易说出口 提交于 2019-11-26 06:48:11
问题 I am using JSF 2.0. I created custom JSTL tags with tagfiles and that were working fine in JSP. But I want to use custom JSTL tags in Facelets too. Is it possible to create tagfiles in Facelets or not? 回答1: "Custom JSTL tags" makes honestly no sense. This term is utterly meaningless. JSTL is already a taglib at its own. Please carefully read the introductory paragraphs of our JSTL wiki page to learn what JSTL really is. You perhaps actually meant "Custom JSP tags". Of course they would not

How to implement a dynamic list with a JSF 2.0 Composite Component?

让人想犯罪 __ 提交于 2019-11-26 06:37:29
问题 I asked this question and although the answer directly satisfied my needs I am left with a feeling that there has to a simpler solution for this specific problem. I would like to have a composite component that accepts a list of items (The type of the items agreed upon so the members can be used freely within the composite component) The CC (composite component) display the list of items and allows for addition and subtraction of items. I would like to do this in the most simple and efficient

Which XML namespace to use with JSF 2.2 and up

孤者浪人 提交于 2019-11-26 05:38:14
问题 I have migrated my application from JSF 1.2 to 2.2. It used XML namespaces on java.sun.com domain like xmlns:f=\"http://java.sun.com/jsf/core\" . However, Oracle\'s Java EE 7 tutorial is using XML namespaces on xmlns.jcp.org domain like xmlns:f=\"http://xmlns.jcp.org/jsf/core\" . Which one is recommended and why was this changed? 回答1: Which one is recommended? Go ahead with XML namespaces on xmlns.jcp.org domain. This was newly introduced since Java EE 7 in 2013 (which covers a.o. JSF 2.2,

When using <ui:composition> templating, where should I declare the <f:metadata>?

ⅰ亾dé卋堺 提交于 2019-11-26 04:50:50
I have made a lot of progress in converting my JSF applications to book-markable pages, but I am wondering if I am doing it the right way. One question is that is there a best-practice location for the f:metadata tags? My typical Facelets client page looks like this: <ui:composition template="./pattern.xhtml"> <ui:define name="content"> <f:metadata> <f:viewParam name="userId" value="#{bean.userId}" /> <f:viewParam name="startRecord" value="#{bean.startRecord}" /> <f:viewParam name="pageSize" value="#{bean.pageSize}" /> <f:viewParam name="sort" value="#{bean.sort}" /> </f:metadata> <h1>Data

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

ⅰ亾dé卋堺 提交于 2019-11-26 04:00:43
问题 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? 回答1: 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;

How to invoke a JSF managed bean on a HTML DOM event using native JavaScript?

故事扮演 提交于 2019-11-26 03:13:15
问题 I need to execute a JSF managed bean action method using ajax during HTML DOM load event, similar to jQuery\'s $(document).ready(function() { $.ajax(...) }) . I can only use the JavaScript generated by JSF in this project. Is there a way to do it in native JSF? Which event can I use or which JSF ajax function can I use? I\'m using JSF 2.0, Facelets and PrimeFaces. 回答1: Several ways. Use <h:commandScript> . Note that this is only available since JSF 2.3. <h:form> <h:commandScript name=