IceFaces: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Die Seite wurde neu angelegt: „Kategorie:Framework JavaServerFaces ==Dialog mit Parametern== === sample.xhtml === <pre> <h:form> <h:commandButton id="dialog" value="dialog" onclick="…“ |
Keine Bearbeitungszusammenfassung |
||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| Zeile 16: | Zeile 16: | ||
<h:panelGrid columns="2" width="100%"> | <h:panelGrid columns="2" width="100%"> | ||
<h:outputText value="Wert 1:" /> | <h:outputText value="Wert 1:" /> | ||
<h:outputText id="val1" value="?" /> | <h:outputText id="val1" value="?" /> | ||
<h:outputText value="Wert 2:" /> | <h:outputText value="Wert 2:" /> | ||
<h:outputText id="val2" value="?" /> | <h:outputText id="val2" value="?" /> | ||
</h:panelGrid> | </h:panelGrid> | ||
</h:form> | </h:form> | ||
| Zeile 32: | Zeile 32: | ||
alert("Nicht gefunden: " + id); | alert("Nicht gefunden: " + id); | ||
} else { | } else { | ||
obj.innerHTML = val; | obj.innerHTML = val; | ||
} | } | ||
| Zeile 43: | Zeile 42: | ||
sampleDialog.show(); | sampleDialog.show(); | ||
} | } | ||
</pre> | |||
== Zuschaltbare Details in einer Tabelle == | |||
=== myice.js === | |||
<pre> | |||
function replaceValue(node, args){ | |||
var content = node.innerHTML; | |||
if (content){ | |||
var ix = content.indexOf("!{"); | |||
if (ix >= 0) { | |||
for (var ii = 1; ii <= args.length; ii++){ | |||
content = content.replace("!{" + ii + "}", args[ii - 1]); | |||
} | |||
node.innerHTML = content; | |||
} | |||
} | |||
var elem = node.firstChild; | |||
while (elem){ | |||
replaceValue(elem, args); | |||
elem = elem.nextSibling; | |||
} | |||
while(node){ | |||
node = node.nextSibling; | |||
if (node) | |||
replaceValue(node, args); | |||
} | |||
} | |||
function buildNewRow(row, child){ | |||
var rc = row.cloneNode(false); | |||
var colCount = row.childNodes.length; | |||
var col = row.childNodes[0].cloneNode(false); | |||
if (child) | |||
col.appendChild(child); | |||
col.colSpan = colCount; | |||
rc.appendChild(col); | |||
return rc; | |||
} | |||
function buildEmptyRow(row){ | |||
var rc = buildNewRow(row, ""); | |||
return rc; | |||
} | |||
function buildDetails(id, args){ | |||
var root = document.getElementById(id); | |||
if (! root){ | |||
alert("Not found: " + id); | |||
} else { | |||
root = root.cloneNode(true); | |||
replaceValue(root, args); | |||
} | |||
return root; | |||
} | |||
function addRow(child, args){ | |||
var prevRow = child; | |||
do{ | |||
prevRow = prevRow.parentNode; | |||
} while(prevRow.tagName != "TR"); | |||
if (prevRow){ | |||
var content = buildDetails('rowDetail', args).firstChild; | |||
var node = buildNewRow(prevRow, content); | |||
var next = prevRow.nextSibling; | |||
if (! next) | |||
prevRow.parentNode.appendChild(node); | |||
else if (next.childNodes.length > 1) | |||
prevRow.parentNode.insertBefore(node, next); | |||
} | |||
} | |||
</pre> | |||
=== login.xhtml === | |||
<pre> | |||
<h:form id="beantab"> | |||
<ace:dataTable id="usrTable" value="#{sessionBean.users}" var="usr"> | |||
<ace:column id="id" headerText="ID" sortBy="#{usr.id}" | |||
filterBy="#{usr.id}" filterMatchMode="contains"> | |||
<h:outputText id="idCell" value="#{usr.id}" /> | |||
</ace:column> | |||
<ace:column id="uname" headerText="Username" | |||
sortBy="#{usr.username}" filterBy="#{usr.username}" | |||
filterMatchMode="contains"> | |||
<h:outputText id="unameCell" value="#{usr.username}" /> | |||
</ace:column> | |||
<ace:column headerText="Details"> | |||
<h:commandButton value="..." | |||
onclick="addRow(this, [#{usr.id}, '#{usr.username}', '#{usr.name}']);" /> | |||
</ace:column> | |||
</ace:dataTable> | |||
<div id="rowDetail" style="display: none"> | |||
<h:panelGrid columns="2" width="100%"> | |||
<h:outputText value="Id:" /> | |||
<h:outputText value="!{1}" /> | |||
<h:outputText value="Username:" /> | |||
<h:outputText value="!{2}" /> | |||
<h:outputText value="Name:" /> | |||
<h:outputText value="!{3}" /> | |||
</h:panelGrid> | |||
</div> | |||
</h:form> | |||
</pre> | </pre> | ||
Aktuelle Version vom 23. Januar 2013, 22:53 Uhr
Dialog mit Parametern
[Bearbeiten]sample.xhtml
[Bearbeiten]<h:form>
<h:commandButton id="dialog" value="dialog" onclick="myDialog([4711, 'wow!']);" />
</h:form>
<ace:dialog id="dialog" header="A sample dialog overview example"
widgetVar="sampleDialog" closable="true" modal="true"
draggable="false" showEffect="clip" hideEffect="fade" width="400">
<h:form id="dialog_form">
<h:panelGrid columns="2" width="100%">
<h:outputText value="Wert 1:" />
<h:outputText id="val1" value="?" />
<h:outputText value="Wert 2:" />
<h:outputText id="val2" value="?" />
</h:panelGrid>
</h:form>
</ace:dialog>
myice.js
[Bearbeiten]function excText(id, val){
var obj = document.getElementById(id);
if (! obj){
alert("Nicht gefunden: " + id);
} else {
obj.innerHTML = val;
}
return obj;
}
function myDialog(args){
for (var ii = 1; ii <= args.length; ii++){
obj = excText("dialog_form:val" + ii, args[ii-1]);
}
sampleDialog.show();
}
Zuschaltbare Details in einer Tabelle
[Bearbeiten]myice.js
[Bearbeiten]function replaceValue(node, args){
var content = node.innerHTML;
if (content){
var ix = content.indexOf("!{");
if (ix >= 0) {
for (var ii = 1; ii <= args.length; ii++){
content = content.replace("!{" + ii + "}", args[ii - 1]);
}
node.innerHTML = content;
}
}
var elem = node.firstChild;
while (elem){
replaceValue(elem, args);
elem = elem.nextSibling;
}
while(node){
node = node.nextSibling;
if (node)
replaceValue(node, args);
}
}
function buildNewRow(row, child){
var rc = row.cloneNode(false);
var colCount = row.childNodes.length;
var col = row.childNodes[0].cloneNode(false);
if (child)
col.appendChild(child);
col.colSpan = colCount;
rc.appendChild(col);
return rc;
}
function buildEmptyRow(row){
var rc = buildNewRow(row, "");
return rc;
}
function buildDetails(id, args){
var root = document.getElementById(id);
if (! root){
alert("Not found: " + id);
} else {
root = root.cloneNode(true);
replaceValue(root, args);
}
return root;
}
function addRow(child, args){
var prevRow = child;
do{
prevRow = prevRow.parentNode;
} while(prevRow.tagName != "TR");
if (prevRow){
var content = buildDetails('rowDetail', args).firstChild;
var node = buildNewRow(prevRow, content);
var next = prevRow.nextSibling;
if (! next)
prevRow.parentNode.appendChild(node);
else if (next.childNodes.length > 1)
prevRow.parentNode.insertBefore(node, next);
}
}
login.xhtml
[Bearbeiten] <h:form id="beantab">
<ace:dataTable id="usrTable" value="#{sessionBean.users}" var="usr">
<ace:column id="id" headerText="ID" sortBy="#{usr.id}"
filterBy="#{usr.id}" filterMatchMode="contains">
<h:outputText id="idCell" value="#{usr.id}" />
</ace:column>
<ace:column id="uname" headerText="Username"
sortBy="#{usr.username}" filterBy="#{usr.username}"
filterMatchMode="contains">
<h:outputText id="unameCell" value="#{usr.username}" />
</ace:column>
<ace:column headerText="Details">
<h:commandButton value="..."
onclick="addRow(this, [#{usr.id}, '#{usr.username}', '#{usr.name}']);" />
</ace:column>
</ace:dataTable>
<div id="rowDetail" style="display: none">
<h:panelGrid columns="2" width="100%">
<h:outputText value="Id:" />
<h:outputText value="!{1}" />
<h:outputText value="Username:" />
<h:outputText value="!{2}" />
<h:outputText value="Name:" />
<h:outputText value="!{3}" />
</h:panelGrid>
</div>
</h:form>