jsf-2

How to have one instance of Backing Bean per Browser tab?

蹲街弑〆低调 提交于 2020-06-09 05:25:12
问题 My environment : Java 7/JSF 2.1/PrimeFaces 6.1. My goal : to have a certain page of my application instantiated many times, one for each browser tab, each one with a different context. My problem : everytime I open a second browser tab requesting from the same url, but with different object id, the previous one is destroyed, so only one backing bean instance is kept alive. How do I know that : In my backing bean I have one method annotated with @PosConstruct and other with @PreDestroy , so I

Primefaces 5.1 calendar popup doesn't execute the valueChange event

半腔热情 提交于 2020-06-09 02:44:33
问题 I'm try to use the primefaces calendar with popup in this way: <p:calendar pattern="yyyy-MMM-dd" value="#{controller.beginDate}" mask="true" navigator="true"> <f:ajax event="valueChange" listener="#{controller.onChange}" /> </p:calendar> And here is the relative controller: @ManagedBean public class Controller { private Date beginDate; public Date getBeginDate() { return beginDate; } public void setBeginDate(Date beginDate) { this.beginDate = beginDate; } public void onChange() { // do

JSF refreshing list via Ajax incorrectly

无人久伴 提交于 2020-06-01 06:15:17
问题 I am trying to migrate some functionality from JQuery to JSF and I am getting strange results. Basically it is a page where you can navigate links (imagine like a Windows Explorer on the Web). Folders have a link and leafs don't. To construct this, it is used a private List<Element> list; , which is refreshed accordingly. So when the user clicks on a "folder", a new list is created with the contents of that folder. The problem is that I am getting strange results. Sometimes I navigate a link

Calling managed bean methods in JavaScript in with normal HTML button

£可爱£侵袭症+ 提交于 2020-05-27 06:25:11
问题 I need to call managed bean methods in JavaScript while clicking the normal HTML button. Is it possible to do that, provided that I use JSF2.x and Primefaces? 回答1: Yes, it is possible. Primefaces provides for a useful hook to do that with its component <p:remoteCommand>. It basically offers you with a javascript function that will be able to communicate with your bean. Basic usage example: The view: <p:remoteCommand name="remote" actionListener="#{bean.listener}" update="text"/> <h:outputText

Display first page of PDF as Image

橙三吉。 提交于 2020-05-09 19:02:03
问题 I am creating web application where I am displaying images/ pdf in thumbnail format. Onclicking respective image/ pdf it get open in new window. For PDF, I have (this is code of the new window) <iframe src="images/testes.pdf" width="800" height="200" /> Using this I can see all PDF in web browser. However for thumbnail purpose, I want to display only first page of PDF as an Image. I tried <h:graphicImage value="images/testes.pdf" width="800" height="200" /> however it is not working. Any idea

multipart/form-data enctype ignored

梦想与她 提交于 2020-03-26 07:52:09
问题 I have defined a form as multipart/form-data enctype. When I press a command button the request is not send with 'multipart/form-data' content-type. <h:form id="form" method="post" enctype="multipart/form-data"> <input type="file" ></input> <p:commandButton id="save" icon="saveBt" value="#{msgs.saveBt}" ... /> </h:form> In the developer tools console I can see the Content-Type as application/x-www-form-urlencoded; charset=UTF-8. I'm working with JSF 2.1 and Primefaces 5.1. Thanks 回答1: You are

JSF: reloading page via p:button using “?includeViewParams=true” results in %2C for integer GET param in new URL

我与影子孤独终老i 提交于 2020-03-25 13:51:36
问题 I have a page that has two GET params: round = [some integer] group = [some string] See URL above. These are the two components of the group's PK, an INT + a VARCHAR. Facelet code: <f:metadata> <f:viewParam name="round" value="#{groupHandler.roundId}"> <f:convertNumber integerOnly="true" /> </f:viewParam> <f:viewParam name="group" value="#{groupHandler.groupCode}" /> <f:viewAction action="#{groupHandler.loadEntity}" /> </f:metadata> ... <p:button widgetVar="reloadPageButton" value="Reload

JSF: reloading page via p:button using “?includeViewParams=true” results in %2C for integer GET param in new URL

懵懂的女人 提交于 2020-03-25 13:49:11
问题 I have a page that has two GET params: round = [some integer] group = [some string] See URL above. These are the two components of the group's PK, an INT + a VARCHAR. Facelet code: <f:metadata> <f:viewParam name="round" value="#{groupHandler.roundId}"> <f:convertNumber integerOnly="true" /> </f:viewParam> <f:viewParam name="group" value="#{groupHandler.groupCode}" /> <f:viewAction action="#{groupHandler.loadEntity}" /> </f:metadata> ... <p:button widgetVar="reloadPageButton" value="Reload

How to get the URL of current page in JSF?

妖精的绣舞 提交于 2020-03-13 07:15:19
问题 Is there any way to get the URL of the page which is loaded? I would like the URL of the page which is loaded, in my controller i will call a method getUrlOfPage() in init() method . I need the URL source to use it as a input for exporting the context in it. How to get the URL of the page? 回答1: It's available by HttpServletRequest#getRequestURL() (with domain) or getRequestURI() (without domain). The HttpServletRequest itself is in turn available by ExternalContext#getRequest(). Thus, so:

p:dataTable and MalformedByteSequenceException

做~自己de王妃 提交于 2020-03-04 23:06:19
问题 I receive this error when I try to add the tag p:dataTable on my project: An Error Occurred: Byte non valido 1 della sequenza UTF-8 a 1 byte. - Stack Trace com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Byte non valido 1 della sequenza UTF-8 a 1 byte. at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:687) at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:557) at com.sun.org.apache.xerces.internal.impl