The contents.jsp page now displays a list of folders and reports to users, and allows navigation through these folders. To complete the page, several features must be implemented that determine the action to take when the user clicks on various parts of the page.
Click the appropriate link to jump to that section:
Since the path
and foldersList
components are bound to the same EnterpriseItems
bean (representing folders), when users click on one component the other is automatically updated. Therefore, clicking a folder in the folderList
component will update the navigation path in the path component.
However, the reportsList
component on the page is bound to a different EnterpriseItem
bean (representing reports). When users click on a folder in the path
or foldersList
components, reports contained in that folder must be displayed in the reportsList
component. You must synchronize the EnterpriseItems
data between the components for the reports to be displayed.
path
component.reportsList
component to synchronize with the current component.Note: If you try to synchronize with a component that binds to the same EnterpriseItems
bean as other components, a message is displayed that indicates that multiple components share the same itemSource
property value (the EnterpriseItems
bean), and that, if you add synchronization to the selected component, synchronization will be added to all components that are bound to this bean. Click OK to confirm the synchronization.
foldersList
component and repeat steps 2 to 5 to synchronize with the reportsList
component.Clicking on either the path
or foldersList
component now updates the reportsList
component. For additional information, see How do I synchronize multiple ItemsGrid and Path components that bind to different EnterpriseItems beans?
When users click on a report in the reportsList
component, you want to redirect them to the view.jsp page where the report will be rendered. This action is signaled when the ItemClicked
event is triggered. To enable this functionality, several procedures must be performed:
reportsList
component, clear the autoHandleEvents
check box.
When you turn off the default event handling, you can program new behavior for when users click on an item in the grid.
actionListener
attribute of the reportsList
component.
This method obtains the event data and will allow you to set the item ID of the EnterpriseItem
bean (representing a single report) to the ID of the report clicked by the user in the reportsList
component.
For details, see To add an action method to the actionListener attribute.
action
attribute of the reportsList
component.
This method returns an action string. This action string is used by the navigation rules in the faces
file to determine where to redirect users when they click on the reportsList
component.
For details, see To add an action method to the action attribute.
If you have been following the tutorial sequentially, then you have added this navigation rule. See Adding navigation rules for details.
contents.jsp.
RightContents
class of the Contents.java
file:String actionString = "";
import com.businessobjects.jsf.sdk.event.ItemClickedEvent;
Contents.java.
reportsList
component, click the Quick Edit tab.if (event instanceof ItemClickedEvent)
{
ItemClickedEvent currentEvent = (ItemClickedEvent) event;
String reportID = currentEvent.getEventArgs().getItemID();
getEnterpriseItem().setItemID(reportID);
int columnIndex = currentEvent.getEventArgs().getColumnIndex();
if (columnIndex == 0)
{
actionString = "view_report";
}
else
{
actionString = "";
}
}
contents.jsp
.The action method checks to see if the current event triggered is the ItemClicked
event, which indicates that a user clicked an item in the reportsGrid
component. If the ItemClicked
event was triggered by the application, then the report ID of the report clicked is retrieved from the event data:
ItemClickedEvent currentEvent = (ItemClickedEvent) event;
String reportID = currentEvent.getEventArgs().getItemID();
This report ID is then set to the ItemID
property of the EnterpriseItem
bean, to be used as the report source for the ReportPageViewer
component on the next page, view.jsp:
getEnterpriseItem().setItemID(reportID);
Finally, the method checks to see which column of the reportsGrid component was clicked. In this tutorial, only the title of the report (the first column) triggers the application to view the report. If another column is clicked, such as the description of the report, then no action takes place:
int columnIndex = currentEvent.getEventArgs().getColumnIndex();
if (columnIndex == 1)
{
actionString = "view_report";
}
else
{
actionString = "";
}
reportsList
component, click the Quick Edit tab.return actionString;
contents.jsp
.This method returns the action string set by the action method. When users click on the title of the report in the first column of the reportsList
component, this string is set to "view_report".
import com.businessobjects.jsf.sdk.event.ItemClickedEvent;
String actionString = "";
public void doActionListener(ActionEvent event)
{
if (event instanceof ItemClickedEvent)
{
ItemClickedEvent currentEvent = (ItemClickedEvent) event;
String reportID = currentEvent.getEventArgs().getItemID();
getEnterpriseItem().setItemID(reportID);
int columnIndex = currentEvent.getEventArgs().getColumnIndex();
if (columnIndex == 0)
{
actionString = "view_report";
}
else
{
actionString = "";
}
}
}
if (event instanceof ItemClickedEvent)
ItemClickedEvent currentEvent = (ItemClickedEvent) event;
String reportID = currentEvent.getEventArgs().getItemID();
getEnterpriseItem().setItemID(reportID);
int columnIndex = currentEvent.getEventArgs().getColumnIndex();
if (columnIndex == 1)
{
actionString = "view_report";
}
else
{
actionString = "";
}
public String viewReport()
{
return actionString;
}
Business Objects http://www.businessobjects.com/ Support services http://www.businessobjects.com/services/support/ |