User Recipe: View Journal

The View Journal page displays all the entries in a particular journal as well as basic information about the journal itself. The page, in essence, combines information from the Journal and JournalEntries data tables by using two corresponding recordsets. From here, the user can also look at the journal through an archive view or choose to edit any individual entry.

Step 1: Implement Journal Design

The Journal layout includes two distinct areas: one for basic information on the journal and one displaying all the associated entries. The former is a standard label (dynamic data arrangement) whereas the latter uses a repeating region to display the entries by date.

  1. Create a page for the View Journal recipe, either from a template or from the File > New dialog.

    graphics/book.gif In the Journal folder, locate the folder for your server model and open the journal page there.

  2. In the content area of your page, create a header for the page and an area to hold both the general journal information and the specific entries.

    graphics/book.gif From the Snippets panel, drag the Recipes > Journal > Wireframes > Journal Wireframe snippet into the Content editable region.

  3. Add labels and table cells to hold the journal information (name, owner, and description) and, below that, a two row, two column table for the journal entries.

    graphics/book.gif Place your cursor in the first row below the words VIEW JOURNAL and insert the Recipes > Journal > ContentTables > Journal Info - Content Table snippet.

    Place your cursor in the bottom row of the wireframe and insert the Recipes > Journal > ContentTables > View Journal - Content Table snippet [r7-7].


    Figure r7-7.

    graphics/09fig07.jpg


  4. Save the page.

Step 2: Add Database Components

For the two layout areas, two separate data sources are needed. As noted earlier, the Journals and JournalEntries data tables are used to create the recordsets. The Journals table is filtered to include information about the currently selected journal while the JournalEntries table is filtered using the same value to show all the journal's entries.

  1. From the Bindings panel, choose Add (+) and select Recordset.

  2. In the dialog's simple view, enter an appropriate name for the recordset.

    graphics/book.gif Enter Journal in the Name field.

  3. Choose a connection (data source) to use.

    graphics/book.gif Select Recipes from the Connection list.

  4. Choose the table in the data source to work with.

    graphics/book.gif Select Journals (journals for PHP) from the Table list.

  5. Leave the Columns option set to All.

  6. In the Filter area of the Recordset dialog, set the four Filter list elements like this:

    graphics/489fig01.gif

  7. Leave the Sort option set to None and click OK to close the dialog.

Although similar to the Journal recordset, the Entries recordset is filtered differently. Rather than look for a specific entry, this recordset gathers all the entries for the current journal, as represented by the ID parameter in the URL.

  1. From the Bindings panel, choose Add (+) and select Recordset.

  2. In the dialog's simple view, enter an appropriate name for the recordset.

    graphics/book.gif Enter Entries in the Name field.

  3. Choose a connection (data source) to use.

    graphics/book.gif Select Recipes from the Connection list.

  4. Choose the table in the data source to work with.

    graphics/book.gif Select JournalEntries (journalentries for PHP) from the Table list.

  5. Leave the Columns option set to All.

  6. In the Filter area of the Recordset dialog, set the four Filter list elements like this:

    graphics/495fig01.gif

  7. Leave the Sort option set to None and click OK to close the dialog.

  8. Save your page.

Without sorting the Entries recordset, the journal entries will be presented in the order they were stored oldest to newest. You could sort on EntryDate Descending if you wanted to put the newest journal entry first.

Step 3: Data Binding Process

Data fields from the two recordsets must be placed in their separate content areas. In all cases for this page, the data fields can be dropped into position from the Bindings panel.

Let's start by binding data fields from the Journal recordset.

  1. From the Bindings panel, expand the Journal recordset.

  2. Place the data source fields onto the page in their respective areas:

    graphics/book.gif Drag JournalTitle in the cell next to the Journal Name label.

    Drag JournalOwner in the cell next to the Journal Owner label.

    Drag JournalDescription in the cell next to the Journal Description label.

    Select the term [date] in the placeholder text at the top of the content area and drag JournalDate from the Bindings panel onto the selection.

  3. Save the page.

Now, let's add the data fields from the Entries recordset.

  1. From the Bindings panel, expand the Entries recordset.

  2. Place the data source fields onto the page in their respective areas:

    graphics/book.gif Drag EntryDate in the cell below the Date / Time label.

    Select the term [EntryTitle] in the placeholder text at the top of the content area and drag EntryTitle from the Bindings panel onto the selection.

    Select the term [EntryBy] in the placeholder text at the top of the content area and drag EntryBy from the Bindings panel onto the selection.

    Select the term [EntryText] in the placeholder text at the top of the content area and drag EntryText from the Bindings panel onto the selection [r7-8].


    Figure r7-8.

    graphics/09fig08.jpg


  3. Save the page.

Step 4: Assigning Dynamic Links

The Journal page is connected to two other pages in the application: Archive and Journal Editor. The Archive page enables you to see all the journal entries organized by their archiving option, whether it is daily, weekly, or monthly. The Journal Editor, as the name implies, allows an entry to be modified.

  1. Select the text or image you want to link to the archive page.

    graphics/book.gif Choose the phrase View Archive in the upper-right section of the content area.

  2. Select the folder symbol next to the Link field in the Property inspector.

    The Select File dialog opens.

  3. Make sure the dialog is set to Select File Name From File System.

  4. Choose Parameters at the bottom of the dialog.

  5. In the Name column of the Parameters dialog, enter the variable name.

    graphics/book.gif Enter ID in the Name column.

  6. In the Value column, enter the dynamic value of the current survey's ID.

    graphics/book.gif Select the lightning bolt next to the Value column and, from the Dynamic Data dialog, choose JournalID from the Journal recordset. When you're done, click OK once to close the Dynamic Data dialog and again to close the Parameters dialog.

  7. In the Select File dialog, select the file that will be used to edit the survey information.

    graphics/book.gif Choose archive in the Journal folder for your server model.

  8. When you're done, click OK to insert the link.

To make the link to the edit page functional, we'll need to pass two parameters: one identifying the current journal and another for the selected entry.

  1. Select the text or image you want to link to the journal application.

    graphics/book.gif Choose the word [edit] below the Journal label.

  2. Select the folder symbol next to the Link field in the Property inspector.

    The Select File dialog opens.

  3. Make sure the dialog is set to Select File Name From File System.

  4. Choose Parameters at the bottom of the dialog.

  5. In the Name column of the Parameters dialog, enter the variable name.

    graphics/book.gif Enter ID in the Name column.

  6. In the Value column, enter the dynamic value of the current survey's ID.

    graphics/book.gif Select the lightning bolt next to the Value column and, from the Dynamic Data dialog, choose JournalID from the Journal recordset. When you're done, click OK once to close the Dynamic Data dialog.

  7. Choose Add (+) to insert another parameter.

  8. Enter a name for the entry ID variable in the Name column.

    graphics/book.gif Enter EditID in the Name column.

  9. Select the dynamic data for the value.

    graphics/book.gif Select the lightning bolt next to the Value column and, from the Dynamic Data dialog, choose EntryID from the Entries recordset. When you're done, click OK once to close the Dynamic Data dialog and again to close the Parameters dialog.

  10. In the Select File dialog, select the file that will be used to edit the survey information.

    graphics/book.gif Choose journal_editor in the Journal folder for your server model.

  11. When you're done, click OK to insert the link.

Step 5: Adding Repeat Region

The final step on the Journal page is to apply the Repeat Region server behavior. Naturally, the server behavior should only be applied to that area containing multiple records in this case, dynamic data from the Entries recordset.

  1. Select any of the dynamic data fields in the entries content area.

  2. From the Tag Selector, choose the table row tag.

    graphics/book.gif Select the <tr> tag from the Tag Selector.

  3. From the Server Behaviors panel, choose Add (+) and select Repeat Region.

  4. In the Repeat Region dialog, choose the desired recordset.

    graphics/book.gif Choose Entries from the Recordset list.

  5. Set the Show option to display however many records you want.

    graphics/book.gif Choose Show All Records.

  6. Click OK when you're done and save your page.

Note

If the journals are too numerous, you might consider displaying only a limited number of entries. Of course, if you do limit the records in the Repeat Region server behavior, you'll need to add recordset navigation controls, as we've done in previous recipes such as Employee Lookup.


With this step, the page is now complete, and you can see how it looks in the browser or in Live Data view [r7-9]. If you're testing in Live Data view, make sure you have an active ID ready to go in the Live Data Settings. To set one up, choose View > Live Data Settings and then enter ID in the Name column and the desired ID value in the Value column.


Figure r7-9.

graphics/09fig09.jpg




Macromedia Dreamweaver MX 2004 Web Application Recipes
Macromedia Dreamweaver MX 2004 Web Application Recipes
ISBN: 0735713200
EAN: 2147483647
Year: 2003
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net