You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/05/17 08:28:27 UTC
svn commit: r170519 - in /incubator/beehive/trunk/samples/netui-jsf/jsf:
home.java home.jsp physiciansFlow/Controller.java
physiciansFlow/physicianDetail.java physiciansFlow/physicianDetail.jsp
physiciansFlow/search.jsp
Author: rich
Date: Mon May 16 23:28:26 2005
New Revision: 170519
URL: http://svn.apache.org/viewcvs?rev=170519&view=rev
Log:
Checkpoint on the JSF sample:
- Removing all use of HTML and JSTL in favor of JSF components.
- Changing to use page inputs in backing beans.
Modified:
incubator/beehive/trunk/samples/netui-jsf/jsf/home.java
incubator/beehive/trunk/samples/netui-jsf/jsf/home.jsp
incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/Controller.java
incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.java
incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.jsp
incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/search.jsp
Modified: incubator/beehive/trunk/samples/netui-jsf/jsf/home.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-jsf/jsf/home.java?rev=170519&r1=170518&r2=170519&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-jsf/jsf/home.java (original)
+++ incubator/beehive/trunk/samples/netui-jsf/jsf/home.java Mon May 16 23:28:26 2005
@@ -76,8 +76,5 @@
setCommentsPreference("show");
sharedFlow.setCommentsPreference(true);
}
-
- // bypass validation of other components by jumping to render response
- getFacesContext().renderResponse();
}
}
Modified: incubator/beehive/trunk/samples/netui-jsf/jsf/home.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-jsf/jsf/home.jsp?rev=170519&r1=170518&r2=170519&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-jsf/jsf/home.jsp (original)
+++ incubator/beehive/trunk/samples/netui-jsf/jsf/home.jsp Mon May 16 23:28:26 2005
@@ -7,56 +7,39 @@
<body>
<f:view>
<f:loadBundle var="msgs" basename="jsf.messages" />
- <h:form>
- <!-- heading -->
- <table align="center" style="margin-bottom: 15px" >
- <tr>
- <td>
- <h:panelGrid columns="1" >
- <f:facet name="header" >
- <h:outputText value="#{msgs.welcome}" style="font-size: 24; font-weight: bold" />
- </f:facet>
- </h:panelGrid>
- </td>
- </tr>
- </table>
+ <h:form>
+ <!-- heading -->
+ <h:panelGrid columns="1" style="margin-bottom: 15px" >
+ <f:attribute name="align" value="center"/>
+ <h:panelGrid columns="1" >
+ <f:facet name="header" >
+ <h:outputText value="#{msgs.welcome}" style="font-size: 24; font-weight: bold" />
+ </f:facet>
+ </h:panelGrid>
+ </h:panelGrid>
- <!-- intro -->
- <table align="center" width="50%" style="margin-bottom: 15px; border: 1px solid blue; background-color: EEF3FB">
- <tr>
- <td>
- <blockquote>
- <h:outputText value="#{msgs.intro}" />
- </blockquote>
- <blockquote>
- <h:outputText value="#{msgs.homePageComments}" />
- </blockquote>
- </td>
- </tr>
- </table>
+ <!-- intro -->
+ <h:panelGrid cellspacing="20" columns="1" width="50%" style="margin-bottom: 15px; border: 1px solid blue; background-color: EEF3FB">
+ <f:attribute name="align" value="center"/>
+ <h:outputText value="#{msgs.intro}" />
+ <h:outputText value="#{msgs.homePageComments}" />
+ </h:panelGrid>
- <!-- link to physicians page flow -->
- <table align="center" style="margin-bottom: 30px" >
- <tr>
- <td>
- <h:commandLink action="locatePhysician" value="#{msgs.physicianSearchLinkText}" rendered="true"/>
- </td>
- </tr>
- </table>
-
- <!-- preferences -->
- <table align="center" style="border: solid 1px blue" cellpadding="5">
- <tr>
- <td>
- <h:outputLabel value="#{msgs.commentsPreferenceLabel}" for="commentsPreference" styleClass="widgetLabel" />
- <h:selectOneRadio value="#{backing.commentsPreference}" id="commentsPreference" immediate="true" valueChangeListener="#{backing.commentsPreferenceChange}" onclick="onChange=this.form.submit();" layout="pageDirection" >
- <f:selectItems value="#{backing.commentsPreferenceOptions}" id="commentsPreferenceOptions" />
- </h:selectOneRadio>
- </td>
- </tr>
- </tr>
- </table>
- </h:form>
+ <!-- link to physicians page flow -->
+ <h:panelGrid columns="1" style="margin-bottom: 30px" >
+ <f:attribute name="align" value="center"/>
+ <h:commandLink action="locatePhysician" value="#{msgs.physicianSearchLinkText}" rendered="true"/>
+ </h:panelGrid>
+
+ <!-- preferences -->
+ <h:panelGrid columns="1" style="border: solid 1px blue" cellpadding="5">
+ <f:attribute name="align" value="center"/>
+ <h:outputLabel value="#{msgs.commentsPreferenceLabel}" for="commentsPreference" styleClass="widgetLabel" />
+ <h:selectOneRadio value="#{backing.commentsPreference}" id="commentsPreference" immediate="true" valueChangeListener="#{backing.commentsPreferenceChange}" layout="pageDirection" >
+ <f:selectItems value="#{backing.commentsPreferenceOptions}" id="commentsPreferenceOptions" />
+ </h:selectOneRadio>
+ </h:panelGrid>
+ </h:form>
</f:view>
</body>
</html>
Modified: incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/Controller.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/Controller.java?rev=170519&r1=170518&r2=170519&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/Controller.java (original)
+++ incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/Controller.java Mon May 16 23:28:26 2005
@@ -115,47 +115,59 @@
return new Forward("success");
}
- @Jpf.Action(forwards = {
- @Jpf.Forward(name = "success",
- path = "physicianDetail.faces",
- actionOutputs = {
- @Jpf.ActionOutput(name = "physicianDetail",
- type = Physician.class,
- required = false)
- })
- })
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(
+ name = "success",
+ path = "physicianDetail.faces",
+ actionOutputs={
+ @Jpf.ActionOutput(
+ name="physician",
+ type = Physician.class,
+ required = true
+ )
+ }
+ )
+ }
+ )
protected Forward physicianDetail()
{
Forward success = new Forward("success");
String paramValue = getRequest().getParameter("physicianId");
int id = TypeUtils.convertToInt(paramValue);
- Physician physicianDetail = physicianSession.getPhysician(id);
- success.addActionOutput("physicianDetail", physicianDetail);
+ Physician physician = physicianSession.getPhysician(id);
+ success.addActionOutput("physician", physician);
return success;
}
- @Jpf.Action(forwards = {
- @Jpf.Forward(name = "success",
- path = "physicianDetail.faces",
- actionOutputs = {
- @Jpf.ActionOutput(name = "physicianDetail",
- type = Physician.class,
- required = false)
- })
- })
/*
* This action is equivalent to the "physicianDetail" action above
* but the row data (physician) is gotten directly from the JSF DataModel.
*/
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(
+ name = "success",
+ path = "physicianDetail.faces",
+ actionOutputs={
+ @Jpf.ActionOutput(
+ name="physician",
+ type = Physician.class,
+ required = true
+ )
+ }
+ )
+ }
+ )
protected Forward physicianDetailJSFStyle()
{
Forward success = new Forward("success");
assert(this.results != null);
- Physician physicianDetail = (Physician)results.getRowData();
- success.addActionOutput("physicianDetail", physicianDetail);
+ Physician physician = (Physician)results.getRowData();
+ success.addActionOutput("physician", physician);
return success;
}
@@ -190,8 +202,8 @@
{
Forward success = new Forward("success");
success.addActionOutput("mailMessage", form.getMessage());
- success.addActionOutput("firstName", getRequest().getParameter("firstName"));
- success.addActionOutput("lastName", getRequest().getParameter("lastName"));
+ success.addActionOutput("firstName", form.getPhysician().getFirstName());
+ success.addActionOutput("lastName", form.getPhysician().getLastName());
return success;
}
@@ -200,6 +212,7 @@
//
public static class MailMessageForm extends FormData
{
+ private Physician physician;
private String message;
public void setMessage(String message)
@@ -210,6 +223,16 @@
public String getMessage()
{
return this.message;
+ }
+
+ public void setPhysician(Physician physician)
+ {
+ this.physician = physician;
+ }
+
+ public Physician getPhysician()
+ {
+ return this.physician;
}
}
Modified: incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.java?rev=170519&r1=170518&r2=170519&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.java (original)
+++ incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.java Mon May 16 23:28:26 2005
@@ -4,6 +4,7 @@
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import jsf.physiciansFlow.Controller.MailMessageForm;
+import jsf.physician.Physician;
/**
* This is the backing bean for JSF page "physicianDetail.faces" (physicianDetail.jsp).
@@ -13,6 +14,15 @@
{
private MailMessageForm mailForm = new MailMessageForm();
+ protected void onCreate()
+ {
+ // Initialize the MailMessageForm with the passed-in page input (passed as an action output
+ // from the calling action. We will pass this form bean to action "submitMailMessage" from
+ // a commandButton on physicianDetail.jsp.
+ mailForm = new MailMessageForm();
+ mailForm.setPhysician((Physician) getPageInput("physician"));
+ }
+
public void setMailForm(MailMessageForm form)
{
mailForm = form;
Modified: incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.jsp?rev=170519&r1=170518&r2=170519&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.jsp (original)
+++ incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/physicianDetail.jsp Mon May 16 23:28:26 2005
@@ -74,11 +74,11 @@
</tr>
<tr>
<td align="right" >
- <h:commandLink action="submitMailMessage" value="Send Mail" tabindex="1" >
+ <h:commandButton action="submitMailMessage" value="Send Mail" tabindex="1" >
<f:attribute name="submitFormBean" value="backing.mailForm" />
<f:param name="firstName" value="#{pageInput.physicianDetail.firstName}" />
<f:param name="lastName" value="#{pageInput.physicianDetail.lastName}" />
- </h:commandLink>
+ </h:commandButton>
</td>
</tr>
</table>
Modified: incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/search.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/search.jsp?rev=170519&r1=170518&r2=170519&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/search.jsp (original)
+++ incubator/beehive/trunk/samples/netui-jsf/jsf/physiciansFlow/search.jsp Mon May 16 23:28:26 2005
@@ -9,78 +9,55 @@
</head>
<body>
<f:view>
- <f:loadBundle var="msgs" basename="jsf.physiciansFlow.messages" />
+ <f:loadBundle var="msgs" basename="jsf.physiciansFlow.messages" />
<h:form>
- <!-- navigation links -->
- <table align="center" cellspacing="0" cellpadding="0" width="90%" style="margin-bottom: 30; padding-bottom: 5px; border-bottom: 2px solid blue" >
- <tr>
- <td align="left" >
- <h:commandLink action="shared.home" value="Home" />
- </td>
- </tr>
- </table>
-
- <!-- the search form -->
- <table width="470" height="130" align="center" cellpadding="7" style="margin-bottom: 30; border: solid 1px blue" >
- <tr>
- <td>
- <h:outputLabel value="#{msgs.physicianTypeLabel}" for="physicianType" styleClass="widgetLabel" />
- <h:selectOneRadio value="#{backing.physicianType}" id="physicianType" immediate="true" valueChangeListener="#{backing.physicianTypeChange}" onclick="onChange=this.form.submit();" layout="pageDirection" >
- <f:selectItems value="#{backing.physicianTypes}" id="physicianTypes" />
- </h:selectOneRadio>
- </td>
- <td> </td>
- </tr>
- <tr>
- <td>
- <h:outputLabel value="#{msgs.specialistTypeLabel}" for="specialistType "styleClass="widgetLabel" />
- <h:selectOneMenu value="#{backing.criteria.specialty}" disabled="#{backing.specialistsDisabled}" id="specialistType" styleClass="selectMenu" >
- <f:selectItems value="#{backing.specialistTypes}" id="specialistTypes" />
- </h:selectOneMenu>
- </td>
- <td> </td>
- </tr>
- <tr>
- <td>
- <h:outputLabel value="#{msgs.cityLabel}" for="city" styleClass="widgetLabel" />
- <h:selectOneMenu value="#{backing.criteria.city}" id="city" required="true" styleClass="selectMenu" >
- <f:selectItems value="#{backing.cities}" id="cities" />
- </h:selectOneMenu>
- </td>
- <td>
-
- <h:message for="city" styleClass="validationMessage" style="color:#ff0000;" />
- </td>
- </tr>
- <tr>
- <td>
- <h:outputLabel value="#{msgs.resultsFormatTypeLabel}" for="resultFormatType" styleClass="widgetLabel" />
- <h:selectOneRadio value="#{backing.resultFormatType}" id="resultFormatType" layout="pageDirection" >
- <f:selectItems value="#{backing.resultFormatTypes}" id="resultFormatTypes" />
- </h:selectOneRadio>
- </td>
- <td> </td>
- </tr>
- <tr>
+ <!-- navigation links -->
+ <h:panelGrid columns="1" cellspacing="0" cellpadding="0" width="90%" style="margin-bottom: 30; padding-bottom: 5px; border-bottom: 2px solid blue" >
+ <f:attribute name="align" value="center"/>
+ <h:commandLink action="shared.home" value="Home" />
+ </h:panelGrid>
+
+ <!-- the search form -->
+ <h:panelGrid columns="2" width="470" cellpadding="7" style="margin-bottom: 30; border: solid 1px blue" >
+ <f:attribute name="align" value="center"/>
+
+ <h:outputLabel value="#{msgs.physicianTypeLabel}" for="physicianType" styleClass="widgetLabel" />
+ <h:selectOneRadio value="#{backing.physicianType}" id="physicianType" immediate="true" valueChangeListener="#{backing.physicianTypeChange}" onclick="onChange=this.form.submit();" layout="pageDirection" >
+ <f:selectItems value="#{backing.physicianTypes}" id="physicianTypes" />
+ </h:selectOneRadio>
+
+ <h:outputLabel value="#{msgs.specialistTypeLabel}" for="specialistType "styleClass="widgetLabel" />
+ <h:selectOneMenu value="#{backing.criteria.specialty}" disabled="#{backing.specialistsDisabled}" id="specialistType" styleClass="selectMenu" >
+ <f:selectItems value="#{backing.specialistTypes}" id="specialistTypes" />
+ </h:selectOneMenu>
+
+ <h:outputLabel value="#{msgs.cityLabel}" for="city" styleClass="widgetLabel" />
+
+ <h:panelGrid columns="2">
+ <h:selectOneMenu value="#{backing.criteria.city}" id="city" required="true" styleClass="selectMenu" >
+ <f:selectItems value="#{backing.cities}" id="cities" />
+ </h:selectOneMenu>
+ <h:message for="city" styleClass="validationMessage" style="color:#ff0000;" />
+ </h:panelGrid>
+
+ <h:outputLabel value="#{msgs.resultsFormatTypeLabel}" for="resultFormatType" styleClass="widgetLabel" />
+ <h:selectOneRadio value="#{backing.resultFormatType}" id="resultFormatType" layout="pageDirection" >
+ <f:selectItems value="#{backing.resultFormatTypes}" id="resultFormatTypes" />
+ </h:selectOneRadio>
+
<!-- here we submit a form to an action handler in the backing file -->
- <td>
- <h:commandButton action="#{backing.execute}" styleClass="submitButton" id="searchButton" value="Search" />
- </td>
- <td> </td>
- </tr>
- </table>
+ <h:commandButton action="#{backing.execute}" styleClass="submitButton" id="searchButton" value="Search" />
+ <f:facet name="td"/>
+ </h:panelGrid>
- <!-- message to user -->
- <table align="center" style="margin-bottom: 15" >
- <tr>
- <td>
- <h:outputText value="#{msgs.searchResultsYes}" styleClass="infoMessage" rendered="#{pageFlow.results.rowCount > 0}" />
- <h:outputText value="#{msgs.searchResultsNo}" styleClass="infoMessage" rendered="#{pageFlow.results.rowCount == 0}" />
- </td>
- </tr>
- </table>
-
- <!-- search results -->
+ <!-- message to user -->
+ <h:panelGrid style="margin-bottom: 15" >
+ <f:attribute name="align" value="center"/>
+ <h:outputText value="#{msgs.searchResultsYes}" styleClass="infoMessage" rendered="#{pageFlow.results.rowCount > 0}" />
+ <h:outputText value="#{msgs.searchResultsNo}" styleClass="infoMessage" rendered="#{pageFlow.results.rowCount == 0}" />
+ </h:panelGrid>
+
+ <!-- search results -->
<h:dataTable value="#{pageFlow.results}" var="physician" rendered="#{pageFlow.results != null}" styleClass="resultsTable" rowClasses="oddRow, evenRow" id="searchResults" cellpadding="7px" >
<h:column>
<f:facet name="header" >
@@ -96,16 +73,16 @@
</h:column>
<h:column>
<f:facet name="header" >
- <h:commandLink action="#{backing.sortByLastName}" immediate="true" >
- <h:outputText value="#{msgs.lastNameColumnLabel}" />
+ <h:commandLink action="#{backing.sortByLastName}" immediate="true" >
+ <h:outputText value="#{msgs.lastNameColumnLabel}" />
</h:commandLink>
</f:facet>
<h:outputText value="#{physician.lastName}" />
</h:column>
<h:column>
<f:facet name="header" >
- <h:commandLink action="#{backing.sortByGender}" immediate="true" >
- <h:outputText value="#{msgs.genderColumnLabel}" />
+ <h:commandLink action="#{backing.sortByGender}" immediate="true" >
+ <h:outputText value="#{msgs.genderColumnLabel}" />
</h:commandLink>
</f:facet>
<h:outputText value="#{physician.gender}" />
@@ -118,58 +95,50 @@
</h:column>
<h:column>
<f:facet name="header" >
- <h:outputText value="#{msgs.detailsColumnLabel}" />
+ <h:outputText value="#{msgs.detailsColumnLabel}" />
</f:facet>
<!-- Here we call a page flow action directly -->
<h:commandLink value="#{msgs.detailLabel}" action="physicianDetail" >
- <f:param name="physicianId" value="#{physician.id}" />
+ <f:param name="physicianId" value="#{physician.id}" />
</h:commandLink>
</h:column>
</h:dataTable>
</h:form>
-
- <!-- explanatory comment block -->
- <c:if test="${sharedFlow.shared.commentsPreference}">
- <table align="center" width="90%" style="background-color: #EEF3FB; margin-bottom: 30; border:1px solid blue;">
- <tr>
- <td>
- <h:outputText value="#{msgs.commentsHeading}" rendered="#{sharedFlow.shared.commentsPreference}" style="font-weight: bold" />
- </td>
- </tr>
- <tr>
- <td>
- <blockquote>
- <h:outputText value="#{msgs.searchPageCommentOne}" rendered="#{sharedFlow.shared.commentsPreference}" />
- </blockquote>
- <pre>
- @Jpf.CommandHandler(
- raiseActions = {
- @Jpf.RaiseAction(action="displayPhysiciansWithDetail", outputFormBean="searchForm"),
- @Jpf.RaiseAction(action="displayPhysiciansAbbreviated", outputFormBean="searchForm")
- }
- )
- </pre>
- <blockquote>
- <h:outputText value="#{msgs.searchPageCommentTwo}" rendered="#{sharedFlow.shared.commentsPreference}" />
- </blockquote>
- <pre>
- <h:commandLink value="#{msgs.detailLabel} #{physician.id}" action="physicianDetail" >
- <f:param name="physicianId" value="#{physician.id}" />
- </h:commandLink>
- </pre>
- <blockquote>
- <h:outputText value="#{msgs.searchPageCommentThree}" rendered="#{sharedFlow.shared.commentsPreference}" />
- </blockquote>
- <blockquote>
- <h:outputText value="#{msgs.searchPageCommentFour}" rendered="#{sharedFlow.shared.commentsPreference}" />
- </blockquote>
- <blockquote>
- <h:outputText value="#{msgs.searchPageCommentFive}" rendered="#{sharedFlow.shared.commentsPreference}" />
- </blockquote>
- </td>
- </tr>
- </table>
- </c:if>
+
+ <!-- explanatory comment block -->
+ <h:panelGrid width="90%" cellpadding="5" style="background-color: #EEF3FB; margin-bottom: 30; border:1px solid blue;" rendered="#{sharedFlow.shared.commentsPreference}">
+ <h:outputText value="#{msgs.commentsHeading}" rendered="#{sharedFlow.shared.commentsPreference}" style="font-weight: bold" />
+
+ <h:outputText value="#{msgs.searchPageCommentOne}" rendered="#{sharedFlow.shared.commentsPreference}" />
+ <f:verbatim>
+ <pre>
+ @Jpf.CommandHandler(
+ raiseActions = {
+ @Jpf.RaiseAction(action="displayPhysiciansWithDetail", outputFormBean="searchForm"),
+ @Jpf.RaiseAction(action="displayPhysiciansAbbreviated", outputFormBean="searchForm")
+ }
+ )
+ </pre>
+ </f:verbatim>
+
+
+ <h:outputText value="#{msgs.searchPageCommentTwo}" rendered="#{sharedFlow.shared.commentsPreference}" />
+ <f:verbatim>
+ <pre>
+ <h:commandLink value="#{msgs.detailLabel}" action="physicianDetail" >
+ <f:param name="physicianId" value="#{physician.id}" />
+ </h:commandLink>
+ </pre>
+ </f:verbatim>
+
+
+ <h:outputText value="#{msgs.searchPageCommentThree}" rendered="#{sharedFlow.shared.commentsPreference}" />
+
+ <h:outputText value="#{msgs.searchPageCommentFour}" rendered="#{sharedFlow.shared.commentsPreference}" />
+
+ <h:outputText value="#{msgs.searchPageCommentFive}" rendered="#{sharedFlow.shared.commentsPreference}" />
+ </h:panelGrid>
+
</f:view>
</body>
</html>