jsf-2.2

What exactly does JSF h:form tag

依然范特西╮ 提交于 2020-01-07 06:58:26
问题 Could someone explain in own words how exactly h:form works and what is it good for ? I am completely new to JSF and I noticed strange behaviour. Let's say I have a button which redirect me to home page like this: h:commandButton value="back" action="home?faces-redirect=true" When I don't wrap this button into h:form tag button simply doesn't work... What exactly do h:form behind the scene ? I have read official documentation but I don't feel that I know how it works... Thanks 回答1: It places

JSF Primefaces: Update a dataTable open in another tab?

为君一笑 提交于 2020-01-06 20:03:37
问题 I have a simple webapp which allows the user to create transactions, and on another page the user can see all past transactions. I would like: To have the dataTable be up-to-date when I open the past transaction page To update the dataTable when I create a transaction on the creation page I am not sure if this can be covered by one or two functionalities. Also, I am not sure how to decouple the functionalities. Should the creation of a transaction trigger the refresh of the dataTable , or

p:dataTable with converters/validators. Rows being editted on other than the first page do not stay in edit mode on conversion/validation violation

霸气de小男生 提交于 2020-01-05 12:50:37
问题 Consider any simple <p:dataTable> with any JSF validator(s) / converter(s). Given below a cut-down version as an example to reduce complexity. <p:column> <p:cellEditor> <f:facet name="output"> <h:outputText value="#{row.value}"/> </f:facet> <f:facet name="input"> <p:inputText value="#{row.value}" required="true"/> </f:facet> </p:cellEditor> </p:column> The given <p:inputText> is mandatory. Naturally, if a <p:row> is edited (using a <p:rowEditor> ) and the given validation is violated on

How to make selected h:selectOneRadio of h:dataTable remain selected on postback?

半腔热情 提交于 2020-01-05 03:48:28
问题 In normal circumstances like this: <h:form> <h:selectOneRadio value="#{bean.gender}"> <f:selectItem itemValue="Male" itemLabel="Male" /> <f:selectItem itemValue="Female" itemLabel="Female" /> <f:selectItem itemValue="Other" itemLabel="Other" /> </h:selectOneRadio> <h:commandButton value="Submit" action="#{bean.action}" /> </h:form> Selecting one radio button disselects the other & the radio button will be remain selected on the postback. (when the same view is rendered) However, when we're

What is the purpose of rendered attribute on f:viewAction?

纵然是瞬间 提交于 2020-01-05 03:04:15
问题 The description of the rendered attribute of f:viewAction is not clear in the official documentation. I was thinking that, if it contained an expression that evaluated to false, the action expression would not be executed like in the following example: <f:viewAction action="#{javax.enterprise.context.conversation.begin()}" rendered="#{javax.enterprise.context.conversation.isTransient()}" /> But the action is always executed no matter what the rendered attribute evaluates to. So what is its

JSF NumberFormatException with f:setPropertyActionListener

核能气质少年 提交于 2020-01-05 02:58:05
问题 I'm getting this error with f:setPropertyActionListener and i can't figure out why: HTTP Status 500 - For input string: "selectedItem" exception: javax.servlet.ServletException: For input string: "selectedItem" javax.faces.webapp.FacesServlet.service(FacesServlet.java:667) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause: java.lang.NumberFormatException: For input string: "selectedItem" java.lang.NumberFormatException.forInputString(Unknown Source) java.lang

Importance of Serializable interface while creating a session scoped managed bean

好久不见. 提交于 2020-01-04 14:52:47
问题 I can't understand how serialization works in session scoped JSF managed beans. Why is implementation of Serializable interface important while creating a session scoped JSF managed bean? 回答1: @SessionScoped beans are ultimately stored in the user's HTTP session. This means that when a Java EE deployment implements a session preservation scheme (for example, tomcat will attempt to save current sessions to a .ser file on server shutdown, if the deployer so chooses), those session-scoped beans

Importance of Serializable interface while creating a session scoped managed bean

本秂侑毒 提交于 2020-01-04 14:52:34
问题 I can't understand how serialization works in session scoped JSF managed beans. Why is implementation of Serializable interface important while creating a session scoped JSF managed bean? 回答1: @SessionScoped beans are ultimately stored in the user's HTTP session. This means that when a Java EE deployment implements a session preservation scheme (for example, tomcat will attempt to save current sessions to a .ser file on server shutdown, if the deployer so chooses), those session-scoped beans

How to add specific attributes to JSF datatable header

Deadly 提交于 2020-01-04 13:26:32
问题 I am using JSF 2.2 and want to add some specific attributes to the datatable header row. The end result in HTML should look something like this. <table> <th my-attribute="myattributevalue"> Header Column </th> .... Is this possible in JSF? 回答1: Use the <f:passThroughAttribute/> to set custom attributes. The th can be rendered by setting rowHeader="true" on an <h:column/> <h:dataTable> <h:column rowHeader="true"> <h:outputText value="Header Column"/> <f:passThroughAttribute name="my-attribute"

How to retain/maintain collapse and expand states of <p:panelMenu> even after a page refresh?

↘锁芯ラ 提交于 2020-01-03 06:44:08
问题 Suppose I have the following simple <p:panelMenu> . <p:panelMenu style="width:200px"> <p:submenu label="Contents"> <p:menuitem value="MenuItem1" url="SomeURL" icon="ui-icon-disk" /> <p:menuitem value="MenuItem2" url="SomeURL" icon="ui-icon-disk" /> <p:menuitem value="MenuItem3" url="SomeURL" icon="ui-icon-disk" /> </p:submenu> <p:separator /> <p:submenu label="Users"> <p:menuitem value="MenuItem1" url="SomeURL" icon="ui-icon-disk" /> <p:menuitem value="MenuItem2" url="SomeURL" icon="ui-icon