Advertisement
Guest User

LocationCompositeComponent

a guest
Sep 20th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml"
  4.     xmlns:h="http://java.sun.com/jsf/html"
  5.     xmlns:composite="http://java.sun.com/jsf/composite"
  6.     xmlns:f="http://java.sun.com/jsf/core"
  7.     xmlns:ui="http://java.sun.com/jsf/facelets"
  8.     xmlns:fn="http://java.sun.com/jsp/jstl/functions"
  9.     xmlns:a4j="http://richfaces.org/a4j"
  10.     xmlns:rich="http://richfaces.org/rich">
  11. <head>
  12. <title>Not present in rendered output</title>
  13. </head>
  14. <h:body>
  15.     <composite:interface>
  16.         <composite:attribute name="visibleFieldValue" required="true" />
  17.         <composite:attribute name="hiddenFieldValue" required="true" />
  18.         <composite:clientBehavior name="changeLocation" event="change" targets="visibleId"/>
  19.     </composite:interface>
  20.     <composite:implementation>
  21.         <script type="text/javascript">
  22. /* <![CDATA[ */
  23.   function locationSet(id, name, fieldId, fieldName) {
  24.       fieldName.value = name;
  25.       fieldId.value = id;
  26.     }
  27.     function launchEvent(fieldName) {
  28.         if ("fireEvent" in fieldName) {
  29.           fieldName.fireEvent("onchange");
  30.       } else {
  31.       var evt = document.createEvent("HTMLEvents");
  32.         evt.initEvent("change", false, true);
  33.         fieldName.dispatchEvent(evt);
  34.         }
  35.     }
  36.  
  37.     function locationSelected(id, name, fieldId, fieldName) {
  38.       locationSet(id, name, fieldId, fieldName);
  39.       #{rich:component('popUpPnl')}.hide();
  40.       launchEvent(fieldName);
  41.  
  42.     }
  43.  
  44.     function locationCleared(fieldId, fieldName) {
  45.       locationSet('', '', fieldId, fieldName);
  46.       launchEvent(fieldName);
  47.     }
  48. /* ]]> */
  49.   </script>
  50.         <div id="#{cc.clientId}">
  51.             <h:inputText id="visibleId" value="#{cc.attrs.visibleFieldValue}"
  52.                 readonly="true"
  53.                 onfocus="#{rich:component('popUpPnl')}.show('', {top:'100px', left:'250px'});"/>
  54.             <h:inputHidden id="hiddenId" value="#{cc.attrs.hiddenFieldValue}"
  55.                 converter="es.caib.gesma.gesman.data.converter.LocationConverter" />
  56.             <h:commandButton id="deleteButton"
  57.                 image="/resources/images/icons/textfield_delete.png" alt="Borrar"
  58.                 onclick="javascript:locationCleared(document.getElementById('#{cc.clientId}:hiddenId'), document.getElementById('#{cc.clientId}:visibleId'));return false;" />
  59.             <rich:popupPanel modal="true" id="popUpPnl" autosized="false"
  60.                 minWidth="300" minHeight="500">
  61.                 <f:facet name="header">
  62.                     <h:outputText value="Doble click para seleccionar un valor" />
  63.                 </f:facet>
  64.                 <f:facet name="controls">
  65.                     <h:graphicImage value="/resources/images/icons/cancel.png"
  66.                         style="cursor:pointer"
  67.                         onclick="#{rich:component('popUpPnl')}.hide()" alt="Cerrar" />
  68.                 </f:facet>
  69.                 <rich:tree toggleType="ajax" var="item" >
  70.                     <rich:treeModelRecursiveAdaptor roots="#{masters.rootLocations}"
  71.                         nodes="#{item.divisions}">
  72.                         <rich:treeNode id="locNode"
  73.                             ondblclick="javascript:locationSelected('#{item.id}','#{item.description}',document.getElementById('#{cc.clientId}:hiddenId'), document.getElementById('#{cc.clientId}:visibleId'));">
  74.           #{item.name}
  75.        </rich:treeNode>
  76.                     </rich:treeModelRecursiveAdaptor>
  77.                 </rich:tree>
  78.             </rich:popupPanel>
  79.         </div>
  80.     </composite:implementation>
  81. </h:body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement