viewparams

Process f:viewParam only on page load

馋奶兔 提交于 2019-11-27 09:22:36
I'm using an <f:viewParam> to pass a parameter as follows. <ui:define name="metaData"> <f:metadata> <f:viewParam name="id" value="#{bean.entity}" converter="#{converter}"/> </f:metadata> </ui:define> Is it possible to process this <f:viewParam> , only when the page is loaded/refreshed? It is just because the converter as specified with the <f:viewParam> is costly that converts the value passed through the query-string to a JPA entity. Hence, it involves an expensive database transaction, even when doing ajaxical postbacks using components like <p:commandButton> , <p:commandLink> which is

View-scoped bean recreated on POST when URL parameters not used

允我心安 提交于 2019-11-27 07:50:32
问题 I have a view-scoped JSF-managed bean that's backing an xhtml view where I read one parameter from the URL using f:viewParam . The view presents a form to the user. However, when the user submits the form by pressing the p:commandButton it seems that the view-scoped bean is recreated (I added a @PostConstruct annotation to verify this) and so doesn't remember the instance variable read from the f:viewParam ( invId in the code below). I originally navigate to the view with a GET that includes

Submit a JSF form using GET

柔情痞子 提交于 2019-11-27 04:31:51
问题 How do I submit a form to the same page and use GET parameters? JSF page contents: <f:metadata> <f:viewParam name="item1" value="#{bean.item1}"/> <f:viewParam name="item2" value="#{bean.item2}"/> </f:metadata> ... <h:form> <h:inputText value="#{bean.item1}"/> <h:inputText value="#{bean.item2}"/> <h:button value="Submit" > <f:param name="item1" value="#{bean.item1}"/> <f:param name="item2" value="#{bean.item2}"/> </h:button> </h:form> If I request the page: form.jsf?item1=foo&item2=bar, it

f:viewParam doesn't pass required parameter when new xmlns.jcp.org namespace is used

时光怂恿深爱的人放手 提交于 2019-11-26 17:17:34
问题 I am trying to use Glassfish 4.0 with Java EE 7 XML namespaces to test the sample below. <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core"> <h:head> <title>Title</title> </h:head> <h:body> <h:form> <ul> <ui:repeat value="#{appLoad.movieList}" var="movie"> <li> <h:link value="#{movie.title}" outcome="movie" includeViewParams="true"> <f:param name="id" value="#{movie.id}"/> </h

Handling view parameters in JSF after post

断了今生、忘了曾经 提交于 2019-11-26 15:49:50
问题 I have a few pages that needs a userId to work, thus the following code: userpage.xhtml <!-- xmlns etc. omitted --> <html> <f:metadata> <f:viewParam name="userId" value="#{userPageController.userId}"/> </f:metadata> <f:view contentType="text/html"> <h:head> </h:head> <h:body> <h:form> <h:commandButton action="#{userPageController.doAction}" value="post"/> </h:form> </h:body> </f:view> userPageController.java @Named @ViewScoped public class userPageControllerimplements Serializable { private

Process f:viewParam only on page load

喜你入骨 提交于 2019-11-26 14:42:35
问题 I'm using an <f:viewParam> to pass a parameter as follows. <ui:define name="metaData"> <f:metadata> <f:viewParam name="id" value="#{bean.entity}" converter="#{converter}"/> </f:metadata> </ui:define> Is it possible to process this <f:viewParam> , only when the page is loaded/refreshed? It is just because the converter as specified with the <f:viewParam> is costly that converts the value passed through the query-string to a JPA entity. Hence, it involves an expensive database transaction, even

What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?

僤鯓⒐⒋嵵緔 提交于 2019-11-25 22:15:19
问题 Can anyone clarify how we can use in general, or a in real world example, this snippet? <f:metadata> <f:viewParam id=\"id\" value=\"#{bean.id}\" /> <f:viewAction action=\"#{bean.init}\" /> </f:metadata> 回答1: Process GET parameters The <f:viewParam> manages the setting, conversion and validation of GET parameters. It's like the <h:inputText> , but then for GET parameters. The following example <f:metadata> <f:viewParam name="id" value="#{bean.id}" /> </f:metadata> does basically the following:

ViewParam vs @ManagedProperty(value = “#{param.id}”)

℡╲_俬逩灬. 提交于 2019-11-25 21:53:09
问题 What is the difference between defining View Params like this: <f:metadata> <f:viewParam name=\"id\" value=\"#{someBean.id}\"/> </f:metadata> And defining the property in the ManagedBean like this: @ManagedProperty(value = \"#{param.id}\") private Integer id; 回答1: <f:viewParam>: Sets the value during update model values phase only (since it extends UIInput). The set value is not available during @PostConstruct, so you need an additional <f:event type="preRenderView" listener="#{bean.init}" />