1 / 49

Showtime! An XPage Dynamic Table Managed Bean

Showtime! An XPage Dynamic Table Managed Bean. Russell Maher | President | RGM Consulting rgmconsulting.com XPageTips.com. Who is Russell Maher?. Independent consultant located outside of Chicago Developing, administering, teaching, speaking on Notes/Domino since 1993

kenna
Download Presentation

Showtime! An XPage Dynamic Table Managed Bean

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Showtime! An XPage Dynamic Table Managed Bean Russell Maher | President | RGM Consulting rgmconsulting.com XPageTips.com

  2. Who is Russell Maher? • Independent consultant located outside of Chicago • Developing, administering, teaching, speaking on Notes/Domino since 1993 • Co-presenter of The VIEW Advanced XPages for Domino Developers • XPageTips.com • Managing partner of QDiligence

  3. Agenda • Application Requirements • Architectural Overview • The Code • Deployment • Using the Custom Control

  4. Agenda • Application Requirements • Architectural Overview • The Code • Deployment • Using the Custom Control

  5. What is this about? Domino developers have always needed ability to provide dynamic tables.This presentation describes a dynamic table solution using XPages and managed beans that is easy to administer and deploy.

  6. Application Requirements • Users… • Must be able to add any number of rows to a table within the same document • Must be able to save document as a Draft or Final • If document is not saved, table must be restored next time document is opened • Administrators… • Must be able to configure table without programming • Column Headings • Number of columns • Field types • Field choices • Field validation

  7. Demo!

  8. Agenda • Application Requirements • Architectural Overview • The Code • Deployment • Using the Custom Control

  9. Architectural Overview • Table data is stored on a single document • Repeated fields Answer1_1,Answer1_2,Answer1_3Answer2_1,Answer2_2,Answer2_3Answer3_1,Answer3_2,Answer3_3 • Why? • Less documents • Local data (right on the document) • Easier to code manage

  10. Required Configuration Information • You need a keyed table config document that describes: • # of Columns • Header text for each table column • Field details for each column • Answer is: Radio, Text, Checkbox, Combobox • Field choices (Yes/No, True/False, etc.) • Is field required?

  11. Table Configuration Document

  12. Required Dynamic Table Information • For each dynamic table you must… • Repeat the # of columns • Found in the table configuration document • Repeat the number of rows • Found in the current user document • The document used for data entry • Repeat the number of questions in a row • Found in the table configuration document

  13. Dynamic Table Visualization

  14. Adding A Row • Initially appears simple: • Increment the rowCount for the table by 1 • Add a new row to the table • What happens if document is… • Not saved? • You don’t keep the new rows • Saved as Draft? • You keep the new rows but don’t validate • Saved as Final? • You validate and keep the rows

  15. Deleting a Row • Again appears simple: • Decrement rowCount by 1 • Remove the row from the table • What happens if document is… • Not saved? • You can’t lose them – user expects them next time • Saved as Draft or as Final? • You remove the rows from the table permanently

  16. Gaps. You don’t want ‘em. • You always want: Answer1_1,Answer1_2,Answer1_3Answer2_1,Answer2_2,Answer2_3Answer3_1,Answer3_2,Answer3_3 • You never want “gaps”: Answer5_1,Answer5_2,Answer5_3Answer13_1,Answer13_2,Answer13_3Answer14_1,Answer14_2,Answer14_3

  17. Every Save Requires Normalization • The user document table fields must… • Always accurately reflect the number of rows • Never include missing rows • On document open you must list rowCount number of rows • Gaps will cause problems

  18. Table Field Normalization • When a dynamic table is saved… • You clean the table fields on the document by… • Walking the existing table and removing deleted rows • They are only “hidden” when a user deletes them in case they don’t save • Rebuilding the table using remaining rows • Rearranging the document fields to match new table data • You don’t want any “ghost” table fields lingering about on your document

  19. Field Normalization Visualized

  20. Agenda • Application Requirements • Architectural Overview • The Code • Deployment • Using the Custom Control

  21. Dynamic Binding Act 1 • Expression Language (EL) binds XPage controls to data #{dataSource.fieldname} • EL bindings can be dynamic #{dataSource.SOMEVARIABLE}

  22. Dynamic Binding Act 2 • Custom Controls can have defined properties • Property values can be set at runtime • Property values are provided by the containing XPage/control • Accessed from within the custom control as: • compositeData.propertyname

  23. Dynamic Binding Finale • Dynamic EL binding + Custom Control = #{dataSource[compositeData.propertyname]} • This allows you to have any field on a custom control bind to any field on the document that you wish

  24. Dynamic Binding Illustration

  25. Dynamic Binding Illustration 2

  26. Table_Configuration.xsp • Contains… • Lookup Key Field • Number of Columns Field • Repeat control… • Repeats “Number of Columns” times • Repeats a configTableColumnControl for each column

  27. Table Configuration

  28. configTableColumnControl • Contains… • configColumnLabelControl • Contains column header label for a column • configFieldTypeControl • Defines type of field: Radio, Checkbox, etc. • configFieldChoicesControl • List choices for appropriate fields • configFieldRequiredControl • Is this field required?

  29. configTableColumnControl

  30. UserDocument.xsp • Contains… • A tableBeanDynamicTableControl custom control • Gets single property:the key of the configuration document

  31. tableBeanDynamicTableControl • Contains… • An XPage table control • Repeat control for the column headers • Repeat for the table rows which contains… • Repeat for each row of questions • Buttons • Add New Row • Save as Draft • Save as Final

  32. tableBeanDynamicTableControl DEMO

  33. EL = Bean Connection • Expression Language actually binds controls to a JavaBean • #{dataSource.fieldname} really means “Connect to the dataSource bean and access its fieldname property.”

  34. Managed Beans • Managed beans … • Are Java classes not represented by a UI control • vs. the “backing beans” used by the XPage controls • Are a different way to code your XPage application business logic • Are like agents or script libraries that are running all the time • You just call their functionality whenever you need them to do something

  35. Managed Bean Development Process • Write a Java class • Deploy the managed bean into your NSF • Use EL to bind your XPage controls the your managed bean

  36. Write a Managed Bean Class

  37. TableBean • One managed bean that provides all dynamic table functionality • Represents a single table • Called from the dynamicTableControl • Creates a session scoped representation of the entire table for current document

  38. TableBean Construction Methods • buildBean() • Creates an entire table object • getTableColumnHeadings() • Returns a Vector of column headings • getTableRows() • Returns a Vector of table rows

  39. TableBean Management Methods • addTableRow() • removeTableRow() • cleanTableFields() • saveAsDraft() • saveAsFinal()

  40. Agenda • Application Requirements • Architectural Overview • The Code • Deployment • Using the Custom Control

  41. Managed Bean Deployment • Your Java source files need to be accessible to your NSF • Use the Package Explorer • Create a new source folder • Right-click the project • Use Build Path…New Source Folder… • Place your packaged Java source in the new source folder

  42. Making a Source Folder

  43. Managed Bean Deployment • Tell the NSF the managed bean exists • Package Explorer • Edit faces-config.xml • Give the bean a name • This is the name you use in your code to call the bean • Identify the Java source of the bean • Identify the scope of the managed bean • application, session, view, request, none

  44. Editing faces-config.xml

  45. “Then A Miracle Happens” • Once you have configured your managed bean, the first call to any of its methods instantiates the bean!

  46. Code & Demo Time!

  47. Agenda • Application Requirements • Architectural Overview • The Code • Deployment • Using the Custom Control

  48. Using the Dynamic Table Control • If you want it, you can have it. • http://www.rgmconsulting.com/tablebean • Need to clean the Java code and add more comments then I will send people a link and post publicly.

  49. Questions?? • Thank you! • Visit XPagetips.com • Contact Me If You Have Questions Russell Maher Russ.Maher@rgmconsulting.com

More Related