1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"> <composite:interface> <composite:attribute name="text"/> <composite:editableValueHolder name="text" targets="editableText" /> <composite:actionSource name="editButton" targets="editButton" /> <composite:actionSource name="doneButton" targets="doneButton" /> <composite:clientBehavior name="edit" event="action" targets="editButton"/> <composite:clientBehavior name="done" event="action" targets="doneButton"/> <composite:facet name="textMessage"/> </composite:interface> <composite:implementation> <hutputScript library="javascript" name="prototype.js" target="head"/> <hutputScript library="javascript" name="scriptaculous.js" target="head"/> <hutputScript library="javascript" name="effects.js" target="head"/> <hutputScript library="util" name="inputEditable.js" target="head"/> <div id="#{cc.clientId}"> <hutputText id="text" value="#{cc.attrs.text}"/> <h:commandButton id="editButton" type="button" value="#{cc.resourceBundleMap.editButtonText}" onclick="this.startEditing()"/> <h:inputText id="editableText" value="#{cc.attrs.text}" style="display: none"/> <h:commandButton id="doneButton" value="#{cc.resourceBundleMap.doneButtonText}" style="display: none"> <f:ajax render="text textMessage" execute="editableText" onevent="ajaxExecuting"/> </h:commandButton> <h:panelGroup id="textMessage"> <composite:renderFacet name="textMessage"/> </h:panelGroup> </div> <script> com.clarity.init('#{cc.clientId}'); </script> </composite:implementation> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | package com.corejsf; var com = {}; if (!com.clarity) { com.clarity = { init: function (ccid) { var mydiv = document.getElementById(ccid); mydiv.editButton = $(mydiv.id + ':editButton'); mydiv.text = $(mydiv.id + ':text'); mydiv.editableText = $(mydiv.id + ':editableText'); mydiv.doneButton = $(mydiv.id + ':doneButton'); mydiv.doneButton.offsetLeft = mydiv.editButton.offsetLeft; mydiv.editButton.startEditing = function() { mydiv.text.fade( { duration: 0.25 } ); mydiv.editButton.fade( { duration: 0.25 } ); window.setTimeout( function() { mydiv.editableText.appear( { duration: 0.25 } ); mydiv.doneButton.appear( { duration: 0.25 } ); window.setTimeout( function() { mydiv.editableText.focus(); }, 300); }, 300); }; }, toggleDisplay: function(element) { element.style.display = element.style.display == "none" ? "" : "none"; }, ajaxExecuting: function(data) { var mydiv = $(data.source.parentNode); if (data.status == 'complete') { toggleDisplay(mydiv.editableText); toggleDisplay(mydiv.doneButton); toggleDisplay(mydiv.text); toggleDisplay(mydiv.editButton); } } } } |
1 2 | editButtonText=edit... doneButtonText=done |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |