jsf - Simulation of f:viewAction on master page template -


there application scoped bean.

@named @applicationscoped public class bean {      @inject     private service service;     private entity entity; // getter.     // entity periodically fetched ejb timers on server side     // when fetched notifies associated clients through websockets.     // clients update sending ajax request.     // of these things collectively form different chapter.     // update() needs invoked, when client sends synchronous request      public bean() {}      @postconstruct     private void init() {         consume();     }      private void consume() {         entity = service.getentity();     }      public void update() {         consume();         system.out.println("update called.");     } } 

this bean accessed page included in master template follows (west.xhtml) :

<html lang="#{localebean.language}"       xmlns="http://www.w3.org/1999/xhtml"       xmlns:h="http://xmlns.jcp.org/jsf/html"       xmlns:f="http://xmlns.jcp.org/jsf/core">      <h:form>         <!-- merely fake attempt show expected. -->         <ui:define name="metadata">             <f:metadata>                 <f:viewaction action="{bean.update}"/>             </f:metadata>         </ui:define>          <h:outputtext value="#{bean.entity.field}"/>     </h:form> </html> 

there false attempt invoke update() method using <f:viewaction> master template against semantics.

for function, <f:viewaction> needs repeated on individual template clients makes difficult maintain, when needs changed.

is there possibility avoid <f:viewaction> being repeated on place on every template client?


the master page template looks following. not required. assume above page included using <ui:include src=".."/> in following master template (/web-inf/templates/template.xhtml).

<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">      <f:view locale="..." ...>         <ui:insert name="metadata"></ui:insert>          <h:head>             <title><ui:insert name="title">default title</ui:insert></title>         </h:head>          <h:body>             <h:panelgroup layout="block">                 <ui:insert name="contentbar">                     <!-- file given above included here - west.xhtml. -->                     <ui:include src="/web-inf/template/contents/west.xhtml"/>                 </ui:insert>             </h:panelgroup>              <ui:insert name="content">default contents</ui:insert>              <!--other content bars.-->         </h:body>     </f:view> </html> 

<f:viewaction> needs placed on template clients associated following.

<ui:composition template="/web-inf/templates/template.xhtml"                 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">      <ui:define name="title">page title</ui:define>      <ui:define name="metadata">         <f:metadata>             <f:viewaction action="#{bean.update}"/>         </f:metadata>     </ui:define>      <ui:define name="content">         <!--main contents-->     </ui:define> </ui:composition> 

and forth, <f:viewaction> needs repeated on every such template client coherent task.

is there way declare <f:viewaction> appropriately @ single place there no need repeat on every associated template client?


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -