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 unnecessary.
So, when for example, a <p:commandLink>
(ajaxical) is clicked, the expensive business service (in the converter) should not be executed. Can this be done?
This somehow works (strange enough nevertheless), when the rendered
attribute is evaluated against facesContext.postback
like rendered="#{not facesContext.postback}"
but the attribute rendered
is not documented. Hence, it is unreliable.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…