JSF instances: Component display (hidden) and data ordering

Source: Internet
Author: User
Tags interface return
js| Sort | data | show

The display and concealment of processing components in JSF, the sorting of data, etc. are very easy and straightforward, and are often analyzed and explained by textbooks as examples. The following example comes from a book called "Mastering JavaServer Faces Chinese" (slightly modified) that explains the use of the UI components in JSF by displaying (or hiding) the components and sorting the data.

First look at its interface a total of three (1) index.jsp,

(2) modifyinvoice.jsp, this modified invoice interface has a display (hidden) button, click to Show (or hide) part of the component.

(3) viewinvoices.jsp, display a list of all invoices. And can be sorted by invoice serial number and amount.

Mainly look at this page, when you click on the invoice invoice number, how to correctly return to the modifyinvoice.jsp page (in our own practice must encounter problems ah, the usual approach is the hyperlink with parameters). Of course, first of all, define the navigation rules in the Faces-config.xml file:


   /viewinvoices.jsp   
     modifyinvoice
      /modifyinvoice.jsp
  

From the source can know that this page through a tag to display all invoices.

...

Value= "#{invoice.invoicenumber}" action= "#{viewinvoicespage.modifyinvoice}" >


.....

On top of that, JSF calls the Viewinvoicespage.modifyinvoice method when we click on the serial number of the invoice.

Public String Modifyinvoice () {   Facescontext facescontext = Facescontext.getcurrentinstance ();           Uiviewroot root = Facescontext.getviewroot ();   UIData table = (UIData) root.findcomponent ("Invoiceform"). Findcomponent ("table");   Invoicebean invoice = (Invoicebean) table.getrowdata ();   
Facescontext.getapplication (). createvaluebinding ("#{modifyinvoicepage}"); Modifyinvoicepage detailpage = (modifyinvoicepage) binding.getvalue (facescontext); Detailpage.setinvoice (invoice); return "Modifyinvoice"; }

So it seems that when used When you mark the data, smart JSF uses GetRowData () to know that you clicked on the line (that is, the invoice number, which is actually a JSF to automatically add a row index to the HTML link), and then passes this line of data to the Modifyinvoice.jsp page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.