JSF examples of learning - Component Display (hidden) and data sorting
Abstract: JSF examples of learning - Component Display (hidden) and data sorting
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle">
JSF components in dealing with the display and hidden, the sort of data, such as the framework of other relatively easily and very straightforward, as is often the textbook example of analysis and on. Below this example from Entitled "Mastering JavaServer Faces the Chinese version of" book (with slight changes), through the display components (or hide), and to sort the data on the JSF in the use of UI components.
Let us first look at the interface a total of three (1) index.jsp,
(2) ModifyInvoice.jsp, this revision is a display interface invoices (hide) button, click can display (or hide) of the components.
<table Width="656" border="0"> <tr> <td width="370"> </ td> <td width="276" valign="top"> </ td> </ tr> < / table>
(3) ViewInvoices.jsp that a list of all invoices. And may, by invoice number and amount of sort.
Look at the main page, click on the invoice, the invoice number to the right to return to ModifyInvoice.jsp pages (in the practice of our own problems must ah, it is a normal practice among hyperlinks with parameters) . First of all, of course, faces-config.xml file definition of navigation rules:
From the source can know this page through a
value=”#{viewInvoicesPage.invoices}” var=”invoice” styleClass=”MediumTable” > id=”viewInvoice” styleClass=”Link” title=”View invoice details” value=”#{invoice.invoiceNumber}”/>
…
Value = "# invoice.invoiceNumber) (" action = "# (viewInvoicesPage.modifyInvoice)">
…..
As seen from when we click on the invoice number, call viewInvoicesPage.modifyInvoice JSF methods.
Public String modifyInvoice () = (FacesContext facesContext FacesContext.getCurrentInstance (); UIViewRoot root = facesContext.getViewRoot (); UIData table = (UIData) root.findComponent ( "invoiceForm"). FindComponent (the "table"); InvoiceBean invoice = ( InvoiceBean) table.getRowData (); ValueBinding binding = facesContext.getApplication (). createValueBinding ( "# () modifyInvoicePage"); ModifyInvoicePage detailPage = (ModifyInvoicePage) binding.getValue (facesContext); detailPage.setInvoice (invoice); return "modifyInvoice ";)
In view of this, when used Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back Tags: Component, examples, java jsf, jsfReleated Java Articles
Comments
Leave a Reply






