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: 

  / ViewInvoices.jsp 

  ModifyInvoice 
  / ModifyInvoice.jsp 

  From the source can know this page through a    Markings to indicate all invoices. 

value=”#{viewInvoicesPage.invoices}”

var=”invoice”

styleClass=”MediumTable” >


id=”viewInvoice”

styleClass=”Link”

title=”View invoice details”
  Value = "# invoice.invoiceNumber) (" action = "# (viewInvoicesPage.modifyInvoice)"> 

value=”#{invoice.invoiceNumber}”/>

…..

  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    Marker data show, the clever use JSF getRowData () that you can click on that line (that is, an invoice number, and this is actually JSF will be    Marker to HTML links automatically added to index), then this line data transmission ModifyInvoice.jsp page. 

  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 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: , , ,

Releated Java Articles

Comments

Leave a Reply