jsf-2

How to execute JavaScript after page load?

梦想的初衷 提交于 2019-12-17 19:32:56
问题 I would like to execute a JavaScript function after the page was loaded. At the moment I have a commandButton and everything works fine. However it would be more comfortable if the user is not supposed to hit the button. I have tried f:event, but I do not have a listener, I have only the JavaScript function. Moreover body onload does not work for me as I use only high level components. <f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http:/

Can I use multiple managed bean in the same xhtml page? [closed]

限于喜欢 提交于 2019-12-17 19:17:09
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . when there are data that are repeated in several pages (reference example) Is that I can load into a single managed bean and I use several managed bean in the same page. What is its impact? 回答1: Can I use multiple managed bean in the same xhtml page? Yes, you can, I highly recommend you to try it :

JSF to receive POST parameters

天大地大妈咪最大 提交于 2019-12-17 19:16:50
问题 Today I'm using a servlet to receive a POST from a HTML page and then redirecting to my JSF page. This is my actual Servlet: public class CommInServlet extends HttpServlet { private String reportKey; protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.getSession(true).setAttribute("reportKey", req.getParameter("reportkey")); req.getRequestDispatcher("main.xhtml").forward(req, resp); } } HTML post page: <html> <head /> <body> <form

JSF Conditional includes, cause Component ID has already been found in the view

岁酱吖の 提交于 2019-12-17 19:08:02
问题 I know we can't repeat the ID of any component we have in the same view tree. I have a page which includes another pages by certain condition Like this... <h:panelGroup rendered="#{bean.insertMode == 'SINGLE'}"> <ui:include src="_single.xhtml" /> </h:panelGroup> <h:panelGroup rendered="#{bean.insertMode == 'DOUBLE'}"> <ui:include src="_double.xhtml" /> </h:panelGroup> Now In these pages I have "Almost" the same components hierarchy (Complex) with different actions behaviour (Not only method

How to pass a parameter along with h:commandButton

ε祈祈猫儿з 提交于 2019-12-17 18:56:43
问题 One of the most common approaches to change locale in JSF+Seam - with <h:selectOneMenu> : <h:form action="#{localeSelector.select}" rendered="false"> <h:selectOneMenu value="#{localeSelector.language}" onchange="submit()"> <f:selectItem itemLabel="English" itemValue="en" /> <f:selectItem itemLabel="Francais" itemValue="fr" /> </h:selectOneMenu> </h:form> I want to implement locale changes with buttons. So, the question is - how to pass the parameter (en, fr, etc.) to update the bean with <h

How to change head elements of a page when using ui:composition

隐身守侯 提交于 2019-12-17 18:52:15
问题 I want to ask a question that i have a master template like this <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Login</title> </h:head> <h:body> <div id="top"> <ui:insert name="top"> <ui:include src="header.xhtml" id="header"/> </ui:insert>

How to use jsf.ajax.request to manually send ajax request in JSF

删除回忆录丶 提交于 2019-12-17 18:44:08
问题 I have a table and each row has the 'onclick' configured to call a js function - this part works. I would like the function to issue an ajax request to a method that I can somehow define. Upon return, a div below the table should be rendered. Is this possible? I tried the JS function with the code: <h:outputScript library="javax.faces" name="jsf.js" /> ... function clickAndRender() { jsf.ajax.request(this, event, {render: 'div-to-render'}) } But it doesn't work of course. I have no idea what

JSF f:ajax listener vs commandButton action

ぐ巨炮叔叔 提交于 2019-12-17 18:27:45
问题 I'm curious what is the difference between these two ways of executing ajax calls: <h:commandButton value="Submit" action="#{bean.action}"> <f:ajax execute="@form" render="component"/> </h:commandButton> and <h:commandButton value="Submit"> <f:ajax listener="#{bean.action}" execute="@form" render="component"/> </h:commandButton> It appears that people use the first way more often, but the second seems to work just fine as well... 回答1: The first way allows for navigation by returning a String

Getting warning from JSF: The response was already committed by the time we tried to set the outgoing cookie for the flash

荒凉一梦 提交于 2019-12-17 17:57:56
问题 I have a page1.jsf, in this page i have a commandButton that put an object in ELFlash, and redirects to page2.jsf. In this page i recover the object by ELFlash. Everything works fine. But while the user remains in page2.jsf, for every ajax request, tomcat shows this warning message: 20/07/2013 09:43:37 com.sun.faces.context.flash.ELFlash setCookie WARNING: JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash

Primefaces DataTable + JPA / Hibernate Pagination

拈花ヽ惹草 提交于 2019-12-17 17:54:08
问题 It'll be so cool if i can somehow combine both of these framework together in pagination. Clicking on the next or prev button on the Primefaces Datatable will trigger the query, limiting the query result using JPA. Also perhaps with some mechanism, the primefaces component can also get the total pages from another JPA select count query ? Is there any example on how to put these into work ? Please share your experiences on this. Thank you ! 回答1: You can use a LazyDataModel. In this sample I'm