You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ra...@apache.org on 2005/08/10 23:11:40 UTC
svn commit: r231329 [8/13] - in /jakarta/taglibs/proper/rdc/trunk/src:
META-INF/tags/rdc/ org/apache/taglibs/rdc/ org/apache/taglibs/rdc/core/
org/apache/taglibs/rdc/dm/ org/apache/taglibs/rdc/resources/
org/apache/taglibs/rdc/sampleapps/mortgage/ org/...
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/MortgageAppBean.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/MortgageAppBean.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/MortgageAppBean.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/MortgageAppBean.java Wed Aug 10 14:10:59 2005
@@ -26,138 +26,138 @@
*/
public class MortgageAppBean {
- // The member number of the user
- String memberNumber;
- // The multiple listing service number of the property
- String mlsNumber;
- // The value of the property with the given M.L.S. number
- String propertyValue;
- // The down payment for the mortgage
- String downPayment;
- // The transaction number of the escrow account transfer
- String transactionNum;
- // The result code for the escrow account transfer
- String resultCode;
-
- /*
- * Constructor
- */
- public MortgageAppBean() {
- this.memberNumber = null;
- this.mlsNumber = null;
- this.propertyValue = null;
- this.downPayment = null;
- this.transactionNum = null;
- this.resultCode = null;
- }
-
- /**
- * Gets the down payment for the mortgage
- *
- * @return String the down payment
- */
- public String getDownPayment() {
- return downPayment;
- }
-
- /**
- * Gets the member number
- *
- * @return String the member number
- */
- public String getMemberNumber() {
- return memberNumber;
- }
-
- /**
- * Gets the multiple listing service number
- *
- * @return String the MLS number
- */
- public String getMlsNumber() {
- return mlsNumber;
- }
-
- /**
- * Gets the property value
- *
- * @return String the property value
- */
- public String getPropertyValue() {
- return propertyValue;
- }
-
- /**
- * Gets the property value
- *
- * @return String the property value
- */
- public String getTransactionNum() {
- return transactionNum;
- }
-
- /**
- * Gets the result code
- *
- * @return String the result code
- */
- public String getResultCode() {
- return resultCode;
- }
-
- /**
- * Sets the down payment for the mortgage
- *
- * @param String the new down payment
- */
- public void setDownPayment(String string) {
- downPayment = string;
- }
-
- /**
- * Sets the member number
- *
- * @param String the new member number
- */
-
- public void setMemberNumber(String string) {
- memberNumber = string;
- }
-
- /**
- * Sets the multiple listing service number
- *
- * @param String the new MLS number
- */
- public void setMlsNumber(String string) {
- mlsNumber = string;
- }
-
- /**
- * Sets the property value
- *
- * @param String the new property value
- */
- public void setPropertyValue(String string) {
- propertyValue = string;
- }
-
- /**
- * Sets the transaction number
- *
- * @param String the new transaction number
- */
- public void setTransactionNum(String string) {
- transactionNum = string;
- }
-
- /**
- * Sets the result code
- *
- * @param String the new result code
- */
- public void setResultCode(String string) {
- resultCode = string;
- }
+ // The member number of the user
+ String memberNumber;
+ // The multiple listing service number of the property
+ String mlsNumber;
+ // The value of the property with the given M.L.S. number
+ String propertyValue;
+ // The down payment for the mortgage
+ String downPayment;
+ // The transaction number of the escrow account transfer
+ String transactionNum;
+ // The result code for the escrow account transfer
+ String resultCode;
+
+ /*
+ * Constructor
+ */
+ public MortgageAppBean() {
+ this.memberNumber = null;
+ this.mlsNumber = null;
+ this.propertyValue = null;
+ this.downPayment = null;
+ this.transactionNum = null;
+ this.resultCode = null;
+ }
+
+ /**
+ * Gets the down payment for the mortgage
+ *
+ * @return String the down payment
+ */
+ public String getDownPayment() {
+ return downPayment;
+ }
+
+ /**
+ * Gets the member number
+ *
+ * @return String the member number
+ */
+ public String getMemberNumber() {
+ return memberNumber;
+ }
+
+ /**
+ * Gets the multiple listing service number
+ *
+ * @return String the MLS number
+ */
+ public String getMlsNumber() {
+ return mlsNumber;
+ }
+
+ /**
+ * Gets the property value
+ *
+ * @return String the property value
+ */
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ /**
+ * Gets the property value
+ *
+ * @return String the property value
+ */
+ public String getTransactionNum() {
+ return transactionNum;
+ }
+
+ /**
+ * Gets the result code
+ *
+ * @return String the result code
+ */
+ public String getResultCode() {
+ return resultCode;
+ }
+
+ /**
+ * Sets the down payment for the mortgage
+ *
+ * @param String the new down payment
+ */
+ public void setDownPayment(String string) {
+ downPayment = string;
+ }
+
+ /**
+ * Sets the member number
+ *
+ * @param String the new member number
+ */
+
+ public void setMemberNumber(String string) {
+ memberNumber = string;
+ }
+
+ /**
+ * Sets the multiple listing service number
+ *
+ * @param String the new MLS number
+ */
+ public void setMlsNumber(String string) {
+ mlsNumber = string;
+ }
+
+ /**
+ * Sets the property value
+ *
+ * @param String the new property value
+ */
+ public void setPropertyValue(String string) {
+ propertyValue = string;
+ }
+
+ /**
+ * Sets the transaction number
+ *
+ * @param String the new transaction number
+ */
+ public void setTransactionNum(String string) {
+ transactionNum = string;
+ }
+
+ /**
+ * Sets the result code
+ *
+ * @param String the new result code
+ */
+ public void setResultCode(String string) {
+ resultCode = string;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginAction.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginAction.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginAction.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginAction.java Wed Aug 10 14:10:59 2005
@@ -36,86 +36,86 @@
*/
public class LoginAction extends Action {
- /**
- * Process the specified HTTP request, and create the corresponding
- * HTTP response (or forward to another web component that will create it),
- * with provision for handling exceptions thrown by the business logic.
- */
- public ActionForward execute(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- ActionMessages errors = new ActionMessages();
- ActionForward forward = new ActionForward();
- LoginBean formBean = (LoginBean) form;
-
- boolean loginSuccess = false;
- String mlsPropertyValue = null;
- try {
-
- // Plug for back-end access to login validation
- // Add appropriate arguments
- loginSuccess = validateLogin(formBean.getMemberNumber());
- if ( loginSuccess ) {
- mlsPropertyValue = getMLSPropertyValue(formBean.getMlsNumber());
- }
-
- } catch (Exception e) {
-
- errors.add("LoginAction", new ActionMessage(e.getClass().getName()));
-
- }
-
- // If a message is required, save the specified key(s)
- // into the request for use by the <struts:errors> tag.
- if (!errors.isEmpty()) {
- saveErrors(request, errors);
- }
-
- // Write logic determining how the user should be forwarded.
- if ( loginSuccess ) {
- ((MortgageAppBean)request.getSession().getAttribute("appBean")).
- setMemberNumber(formBean.getMemberNumber());
- ((MortgageAppBean)request.getSession().getAttribute("appBean")).
- setMlsNumber(formBean.getMlsNumber());
- ((MortgageAppBean)request.getSession().getAttribute("appBean")).
- setPropertyValue(mlsPropertyValue);
- request.setAttribute("mlsNumber", formBean.getMlsNumber());
- request.setAttribute("mlsPropertyValue", mlsPropertyValue);
- forward = mapping.findForward("mortgage");
- } else {
- forward = mapping.findForward("re-login");
- }
-
- // Finish with
- return (forward);
-
- }
-
- /**
- * Validate the memberNumber supplied
- *
- * @param memberNum the member number
- * @return boolean indicating login success of failure
- */
- private boolean validateLogin(String memberNum) {
- // Access back-end for login validation, return false if login fails
- return true;
- }
-
- /**
- * Obtain the property value for the property with the given
- * MLS number
- *
- * @param mlsNum the M.L.S. number for the property
- * @return String the property value returned as a string
- */
- private String getMLSPropertyValue(String mlsNum) {
- // Access back-end for
- return "250000";
- }
+ /**
+ * Process the specified HTTP request, and create the corresponding
+ * HTTP response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
+ */
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ ActionMessages errors = new ActionMessages();
+ ActionForward forward = new ActionForward();
+ LoginBean formBean = (LoginBean) form;
+
+ boolean loginSuccess = false;
+ String mlsPropertyValue = null;
+ try {
+
+ // Plug for back-end access to login validation
+ // Add appropriate arguments
+ loginSuccess = validateLogin(formBean.getMemberNumber());
+ if ( loginSuccess ) {
+ mlsPropertyValue = getMLSPropertyValue(formBean.getMlsNumber());
+ }
+
+ } catch (Exception e) {
+
+ errors.add("LoginAction", new ActionMessage(e.getClass().getName()));
+
+ }
+
+ // If a message is required, save the specified key(s)
+ // into the request for use by the <struts:errors> tag.
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
+ }
+
+ // Write logic determining how the user should be forwarded.
+ if ( loginSuccess ) {
+ ((MortgageAppBean)request.getSession().getAttribute("appBean")).
+ setMemberNumber(formBean.getMemberNumber());
+ ((MortgageAppBean)request.getSession().getAttribute("appBean")).
+ setMlsNumber(formBean.getMlsNumber());
+ ((MortgageAppBean)request.getSession().getAttribute("appBean")).
+ setPropertyValue(mlsPropertyValue);
+ request.setAttribute("mlsNumber", formBean.getMlsNumber());
+ request.setAttribute("mlsPropertyValue", mlsPropertyValue);
+ forward = mapping.findForward("mortgage");
+ } else {
+ forward = mapping.findForward("re-login");
+ }
+
+ // Finish with
+ return (forward);
+
+ }
+
+ /**
+ * Validate the memberNumber supplied
+ *
+ * @param memberNum the member number
+ * @return boolean indicating login success of failure
+ */
+ private boolean validateLogin(String memberNum) {
+ // Access back-end for login validation, return false if login fails
+ return true;
+ }
+
+ /**
+ * Obtain the property value for the property with the given
+ * MLS number
+ *
+ * @param mlsNum the M.L.S. number for the property
+ * @return String the property value returned as a string
+ */
+ private String getMLSPropertyValue(String mlsNum) {
+ // Access back-end for
+ return "250000";
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginBean.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginBean.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginBean.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/LoginBean.java Wed Aug 10 14:10:59 2005
@@ -33,71 +33,71 @@
*/
public class LoginBean extends ActionForm {
- // The member number of the user
- private String memberNumber = null;
- // The multiple listing service number of the property
- private String mlsNumber = null;
-
- /**
- * Gets the member number
- *
- * @return String the member number
- */
- public String getMemberNumber() {
- return memberNumber;
- }
-
- /**
- * Sets the member number
- *
- * @param String the new member number
- */
- public void setMemberNumber(String n) {
- this.memberNumber = n;
- }
-
- /**
- * Gets the multiple listing service number
- *
- * @return String the MLS number
- */
- public String getMlsNumber() {
- return mlsNumber;
- }
-
- /**
- * Sets the multiple listing service number
- *
- * @param String the new MLS number
- */
- public void setMlsNumber(String n) {
- this.mlsNumber = n;
- }
-
- /**
- * Reset all bean properties to their default state.
- */
- public void reset(ActionMapping mapping, HttpServletRequest request) {
-
- memberNumber = null;
- mlsNumber = null;
-
- }
-
- /**
- * Validate the properties that have been set for this HTTP request,
- * and return an <code>ActionErrors</code> object that encapsulates
- * any validation errors that have been found.
- */
- public ActionErrors validate(
- ActionMapping mapping,
- HttpServletRequest request) {
+ // The member number of the user
+ private String memberNumber = null;
+ // The multiple listing service number of the property
+ private String mlsNumber = null;
+
+ /**
+ * Gets the member number
+ *
+ * @return String the member number
+ */
+ public String getMemberNumber() {
+ return memberNumber;
+ }
+
+ /**
+ * Sets the member number
+ *
+ * @param String the new member number
+ */
+ public void setMemberNumber(String n) {
+ this.memberNumber = n;
+ }
+
+ /**
+ * Gets the multiple listing service number
+ *
+ * @return String the MLS number
+ */
+ public String getMlsNumber() {
+ return mlsNumber;
+ }
+
+ /**
+ * Sets the multiple listing service number
+ *
+ * @param String the new MLS number
+ */
+ public void setMlsNumber(String n) {
+ this.mlsNumber = n;
+ }
+
+ /**
+ * Reset all bean properties to their default state.
+ */
+ public void reset(ActionMapping mapping, HttpServletRequest request) {
+
+ memberNumber = null;
+ mlsNumber = null;
+
+ }
+
+ /**
+ * Validate the properties that have been set for this HTTP request,
+ * and return an <code>ActionErrors</code> object that encapsulates
+ * any validation errors that have been found.
+ */
+ public ActionErrors validate(
+ ActionMapping mapping,
+ HttpServletRequest request) {
- ActionErrors errors = new ActionErrors();
- StrutsSubmitTag.populate(this, request, errors);
+ ActionErrors errors = new ActionErrors();
+ StrutsSubmitTag.populate(this, request, errors);
- return errors;
+ return errors;
- }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageAction.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageAction.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageAction.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageAction.java Wed Aug 10 14:10:59 2005
@@ -36,89 +36,89 @@
*/
public class MortgageAction extends Action {
- /**
- * Process the specified HTTP request, and create the corresponding
- * HTTP response (or forward to another web component that will create it),
- * with provision for handling exceptions thrown by the business logic.
- */
- public ActionForward execute(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- ActionMessages errors = new ActionMessages();
- ActionForward forward = new ActionForward();
- MortgageBean formBean = (MortgageBean) form;
-
- MortgageData mortgage = null;
- String monthlyInstallment = null;
- String propertyValueStr = ((MortgageAppBean)request.getSession().
- getAttribute("appBean")).getPropertyValue();
- double propertyValue = 0;
- int downpayPercent = 0;
-
- try {
-
- propertyValue = Double.parseDouble(propertyValueStr.trim());
- mortgage = formBean.getMortgage();
- String downpayPercentStr = mortgage.getPercent();
- downpayPercentStr = downpayPercentStr.replaceAll(" ", "");
- downpayPercent = Integer.parseInt(downpayPercentStr);
- monthlyInstallment = getMortgagePayment(mortgage,
- propertyValue);
-
- } catch (Exception e) {
- errors.add("MortgageAction", new ActionMessage(e.getMessage()));
- }
-
- if (propertyValue == 0) {
- errors.add("MortgageAction", new ActionMessage("Zero propertyValue"));
- }
- if (downpayPercent == 0) {
- errors.add("MortgageAction", new ActionMessage("Zero downpayPercent"));
- }
-
- double downPayment = propertyValue * downpayPercent / 100;
- // Truncate cents for better TTS result ... won't work if downPayment > 10^7
- String downPaymentStr = "" + downPayment;
- if (downPaymentStr.indexOf('.') != -1) {
- downPaymentStr = downPaymentStr.substring(0,
- downPaymentStr.indexOf('.'));
- }
-
- // If a message is required, save the specified key(s)
- // into the request for use by the <struts:errors> tag.
- if (!errors.isEmpty()) {
- saveErrors(request, errors);
- }
-
- // Write logic determining how the user should be forwarded.
- if ( formBean.getMortgage() != null ){
- ((MortgageAppBean)request.getSession().getAttribute("appBean")).
- setDownPayment(downPaymentStr);
- request.setAttribute("monthlyInstallment", monthlyInstallment);
- forward = mapping.findForward("ok");
- } else {
- forward = mapping.findForward("redo");
- }
-
- // Finish with
- return (forward);
-
- }
-
- /**
- * Get the monthly installment for the given mortgage
- *
- * @param mortgage the mortgage data
- * @param amount the property value
- * @return String the monthly installment returned as a string
- */
- private String getMortgagePayment(MortgageData mortgage, double amount) {
- // Access back-end for rate lookup
- return "1279";
- }
+ /**
+ * Process the specified HTTP request, and create the corresponding
+ * HTTP response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
+ */
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ ActionMessages errors = new ActionMessages();
+ ActionForward forward = new ActionForward();
+ MortgageBean formBean = (MortgageBean) form;
+
+ MortgageData mortgage = null;
+ String monthlyInstallment = null;
+ String propertyValueStr = ((MortgageAppBean)request.getSession().
+ getAttribute("appBean")).getPropertyValue();
+ double propertyValue = 0;
+ int downpayPercent = 0;
+
+ try {
+
+ propertyValue = Double.parseDouble(propertyValueStr.trim());
+ mortgage = formBean.getMortgage();
+ String downpayPercentStr = mortgage.getPercent();
+ downpayPercentStr = downpayPercentStr.replaceAll(" ", "");
+ downpayPercent = Integer.parseInt(downpayPercentStr);
+ monthlyInstallment = getMortgagePayment(mortgage,
+ propertyValue);
+
+ } catch (Exception e) {
+ errors.add("MortgageAction", new ActionMessage(e.getMessage()));
+ }
+
+ if (propertyValue == 0) {
+ errors.add("MortgageAction", new ActionMessage("Zero propertyValue"));
+ }
+ if (downpayPercent == 0) {
+ errors.add("MortgageAction", new ActionMessage("Zero downpayPercent"));
+ }
+
+ double downPayment = propertyValue * downpayPercent / 100;
+ // Truncate cents for better TTS result ... won't work if downPayment > 10^7
+ String downPaymentStr = "" + downPayment;
+ if (downPaymentStr.indexOf('.') != -1) {
+ downPaymentStr = downPaymentStr.substring(0,
+ downPaymentStr.indexOf('.'));
+ }
+
+ // If a message is required, save the specified key(s)
+ // into the request for use by the <struts:errors> tag.
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
+ }
+
+ // Write logic determining how the user should be forwarded.
+ if ( formBean.getMortgage() != null ){
+ ((MortgageAppBean)request.getSession().getAttribute("appBean")).
+ setDownPayment(downPaymentStr);
+ request.setAttribute("monthlyInstallment", monthlyInstallment);
+ forward = mapping.findForward("ok");
+ } else {
+ forward = mapping.findForward("redo");
+ }
+
+ // Finish with
+ return (forward);
+
+ }
+
+ /**
+ * Get the monthly installment for the given mortgage
+ *
+ * @param mortgage the mortgage data
+ * @param amount the property value
+ * @return String the monthly installment returned as a string
+ */
+ private String getMortgagePayment(MortgageData mortgage, double amount) {
+ // Access back-end for rate lookup
+ return "1279";
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageBean.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageBean.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageBean.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/MortgageBean.java Wed Aug 10 14:10:59 2005
@@ -34,48 +34,48 @@
*/
public class MortgageBean extends ActionForm {
- // The MortgageData supplied by the user
- private MortgageData mortgage = null;
+ // The MortgageData supplied by the user
+ private MortgageData mortgage = null;
- /**
- * Get mortgage
- * @return <code>MortgageData</code> the mortgage information
- */
- public MortgageData getMortgage() {
- return mortgage;
- }
-
- /**
- * Set mortgage
- * @param <code>MortgageData</code> the mortgage information
- */
- public void setMortgage(MortgageData mortgage) {
- this.mortgage = mortgage;
- }
-
- /**
- * Reset all bean properties to their default state.
- */
- public void reset(ActionMapping mapping, HttpServletRequest request) {
-
- mortgage = null;
-
- }
-
- /**
- * Validate the properties that have been set for this HTTP request,
- * and return an <code>ActionErrors</code> object that encapsulates
- * any validation errors that have been found.
- */
- public ActionErrors validate(
- ActionMapping mapping,
- HttpServletRequest request) {
+ /**
+ * Get mortgage
+ * @return <code>MortgageData</code> the mortgage information
+ */
+ public MortgageData getMortgage() {
+ return mortgage;
+ }
+
+ /**
+ * Set mortgage
+ * @param <code>MortgageData</code> the mortgage information
+ */
+ public void setMortgage(MortgageData mortgage) {
+ this.mortgage = mortgage;
+ }
+
+ /**
+ * Reset all bean properties to their default state.
+ */
+ public void reset(ActionMapping mapping, HttpServletRequest request) {
+
+ mortgage = null;
+
+ }
+
+ /**
+ * Validate the properties that have been set for this HTTP request,
+ * and return an <code>ActionErrors</code> object that encapsulates
+ * any validation errors that have been found.
+ */
+ public ActionErrors validate(
+ ActionMapping mapping,
+ HttpServletRequest request) {
- ActionErrors errors = new ActionErrors();
- StrutsSubmitTag.populate(this, request, errors);
+ ActionErrors errors = new ActionErrors();
+ StrutsSubmitTag.populate(this, request, errors);
- return errors;
+ return errors;
- }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedAction.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedAction.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedAction.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedAction.java Wed Aug 10 14:10:59 2005
@@ -37,48 +37,48 @@
*/
public class ProceedAction extends Action {
- /**
- * Process the specified HTTP request, and create the corresponding
- * HTTP response (or forward to another web component that will create it),
- * with provision for handling exceptions thrown by the business logic.
- */
- public ActionForward execute(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception {
-
- ActionMessages errors = new ActionMessages();
- ActionForward forward = new ActionForward();
- ProceedBean formBean = (ProceedBean) form;
-
- String downPayment = ((MortgageAppBean)request.getSession().
- getAttribute("appBean")).getDownPayment();
-
- if (downPayment == null || downPayment.equals("")) {
- errors.add("ProceedAction", new ActionMessage("No down payment value supplied"));
- }
-
- // If a message is required, save the specified key(s)
- // into the request for use by the <struts:errors> tag.
- if (!errors.isEmpty()) {
- saveErrors(request, errors);
- }
-
- // Write logic determining how the user should be forwarded.
- if ( formBean.getMortgageOK().booleanValue() ){
- //This will be returned by the Audium app ... we are skipping one step here
- ((MortgageAppBean)request.getSession().getAttribute("appBean")).
- setTransactionNum(" Z as in Zebra six seven one C as in cat ");
- forward = mapping.findForward("ok");
- } else {
- forward = mapping.findForward("bye");
- }
+ /**
+ * Process the specified HTTP request, and create the corresponding
+ * HTTP response (or forward to another web component that will create it),
+ * with provision for handling exceptions thrown by the business logic.
+ */
+ public ActionForward execute(
+ ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ ActionMessages errors = new ActionMessages();
+ ActionForward forward = new ActionForward();
+ ProceedBean formBean = (ProceedBean) form;
+
+ String downPayment = ((MortgageAppBean)request.getSession().
+ getAttribute("appBean")).getDownPayment();
+
+ if (downPayment == null || downPayment.equals("")) {
+ errors.add("ProceedAction", new ActionMessage("No down payment value supplied"));
+ }
+
+ // If a message is required, save the specified key(s)
+ // into the request for use by the <struts:errors> tag.
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
+ }
+
+ // Write logic determining how the user should be forwarded.
+ if ( formBean.getMortgageOK().booleanValue() ){
+ //This will be returned by the Audium app ... we are skipping one step here
+ ((MortgageAppBean)request.getSession().getAttribute("appBean")).
+ setTransactionNum(" Z as in Zebra six seven one C as in cat ");
+ forward = mapping.findForward("ok");
+ } else {
+ forward = mapping.findForward("bye");
+ }
- // Finish with
- return (forward);
+ // Finish with
+ return (forward);
- }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedBean.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedBean.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedBean.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/mortgage/struts/ProceedBean.java Wed Aug 10 14:10:59 2005
@@ -32,113 +32,113 @@
*/
public class ProceedBean extends ActionForm {
- // User's indication where the mortgage quote is acceptable
- private Boolean mortgageOK = null;
- // The property value
- private String mlsPropertyValue = null;
- // The down payment amount to be transferred to the escrow account
- private String transferAmount = null;
- // The URI where the banking transaction app will submit its results back
- private String submitURI = null;
-
- /**
- * Gets the user's response to the mortgage quote
- *
- * @return Boolean the user's response to the mortgage quote
- */
- public Boolean getMortgageOK() {
- return mortgageOK;
- }
-
- /**
- * Sets the user's response to the mortgage quote
- *
- * @param String the new response to the mortgage quote
- */
- public void setMortgageOK(Boolean b) {
- this.mortgageOK = b;
- }
-
- /**
- * Gets the property value (for the MLS number supplied earlier)
- *
- * @return String the property value
- */
- public String getMlsPropertyValue() {
- return mlsPropertyValue;
- }
-
- /**
- * Sets the property value
- *
- * @param String the new property value
- */
- public void setMlsPropertyValue(String string) {
- this.mlsPropertyValue = string;
- }
-
- /**
- * Gets the submit URI
- *
- * @return String the submit URI
- */
- public String getSubmitURI() {
- return submitURI;
- }
-
- /**
- * Sets the submit URI
- *
- * @param String the new submit URI
- */
- public void setSubmitURI(String string) {
- this.submitURI = string;
- }
-
- /**
- * Gets the transfer amount
- *
- * @return String the amount to be transferred
- */
- public String getTransferAmount() {
- return transferAmount;
- }
-
- /**
- * Sets the transfer amount
- *
- * @param String the new transfer amount
- */
- public void setTransferAmount(String string) {
- this.transferAmount = string;
- }
-
- /**
- * Reset all bean properties to their default state.
- */
- public void reset(ActionMapping mapping, HttpServletRequest request) {
-
- mortgageOK = null;
- mlsPropertyValue = null;
- submitURI = null;
- transferAmount = null;
-
- }
-
- /**
- * Validate the properties that have been set for this HTTP request,
- * and return an <code>ActionErrors</code> object that encapsulates
- * any validation errors that have been found.
- */
- public ActionErrors validate(
- ActionMapping mapping,
- HttpServletRequest request) {
+ // User's indication where the mortgage quote is acceptable
+ private Boolean mortgageOK = null;
+ // The property value
+ private String mlsPropertyValue = null;
+ // The down payment amount to be transferred to the escrow account
+ private String transferAmount = null;
+ // The URI where the banking transaction app will submit its results back
+ private String submitURI = null;
+
+ /**
+ * Gets the user's response to the mortgage quote
+ *
+ * @return Boolean the user's response to the mortgage quote
+ */
+ public Boolean getMortgageOK() {
+ return mortgageOK;
+ }
+
+ /**
+ * Sets the user's response to the mortgage quote
+ *
+ * @param String the new response to the mortgage quote
+ */
+ public void setMortgageOK(Boolean b) {
+ this.mortgageOK = b;
+ }
+
+ /**
+ * Gets the property value (for the MLS number supplied earlier)
+ *
+ * @return String the property value
+ */
+ public String getMlsPropertyValue() {
+ return mlsPropertyValue;
+ }
+
+ /**
+ * Sets the property value
+ *
+ * @param String the new property value
+ */
+ public void setMlsPropertyValue(String string) {
+ this.mlsPropertyValue = string;
+ }
+
+ /**
+ * Gets the submit URI
+ *
+ * @return String the submit URI
+ */
+ public String getSubmitURI() {
+ return submitURI;
+ }
+
+ /**
+ * Sets the submit URI
+ *
+ * @param String the new submit URI
+ */
+ public void setSubmitURI(String string) {
+ this.submitURI = string;
+ }
+
+ /**
+ * Gets the transfer amount
+ *
+ * @return String the amount to be transferred
+ */
+ public String getTransferAmount() {
+ return transferAmount;
+ }
+
+ /**
+ * Sets the transfer amount
+ *
+ * @param String the new transfer amount
+ */
+ public void setTransferAmount(String string) {
+ this.transferAmount = string;
+ }
+
+ /**
+ * Reset all bean properties to their default state.
+ */
+ public void reset(ActionMapping mapping, HttpServletRequest request) {
+
+ mortgageOK = null;
+ mlsPropertyValue = null;
+ submitURI = null;
+ transferAmount = null;
+
+ }
+
+ /**
+ * Validate the properties that have been set for this HTTP request,
+ * and return an <code>ActionErrors</code> object that encapsulates
+ * any validation errors that have been found.
+ */
+ public ActionErrors validate(
+ ActionMapping mapping,
+ HttpServletRequest request) {
- ActionErrors errors = new ActionErrors();
- StrutsSubmitTag.populate(this, request, errors);
+ ActionErrors errors = new ActionErrors();
+ StrutsSubmitTag.populate(this, request, errors);
- return errors;
+ return errors;
- }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/AmazonMenuTemplate.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/AmazonMenuTemplate.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/AmazonMenuTemplate.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/AmazonMenuTemplate.java Wed Aug 10 14:10:59 2005
@@ -37,144 +37,144 @@
* @author Rahul Akolkar
*/
public class AmazonMenuTemplate extends RDCTemplate
- implements BaseModel.ValueInterpreter {
+ implements BaseModel.ValueInterpreter {
- /**A constant for Error Code stating no category from the menu
- * has been specified */
- public static final int ERR_NO_CATEGORY = 1;
- public final int getERR_NO_CATEGORY() { return ERR_NO_CATEGORY; }
-
- // Component Grammars
- private Grammar mainGrammar;
- private Grammar categoryGrammar;
- public void setMainGrammar(Grammar g) { mainGrammar = g; }
- public void setCategoryGrammar(Grammar g) { categoryGrammar = g; }
-
- /**
- * Sets default values for all data members
- */
- public AmazonMenuTemplate() {
- super();
- this.value = new AmazonMenuResult();
- this.mainGrammar = null;
- this.categoryGrammar = null;
- this.populateGrammars = true;
- }
-
- /**
- * Sets the new value
- *
- * @see org.apache.taglibs.rdc.core.BaseModel.ValueInterpreter#setValueFromInterpretation()
- */
- public void setValueFromInterpretation() {
- String genre = (String) interpretation.get(AmazonMenuResult.SI_GENRE);
- String category = (String) interpretation.get(AmazonMenuResult.
- SI_CATEGORY);
- if (genre == null && category == null) {
- value = baseCanonicalize((String)interpretation.get(Constants.
- STR_EMPTY));
- } else {
- if (genre != null && genre.length() > 0) {
- ((AmazonMenuResult) value).setGenre(genre);
- }
- if (category != null && category.length() > 0) {
- ((AmazonMenuResult) value).setCategory(category);
- }
- }
- setIsValid(baseValidate(value, true));
-
- setCanonicalizedValue(((AmazonMenuResult) value).getReadableValue());
- }
-
- /**
- * Initialize the component grammars for first round trip
- *
- * @see RDCTemplate#initComponentGrammars()
- */
- public void initComponentGrammars() {
- // start with main grammar + initial if applicable
- this.grammars.remove(categoryGrammar);
- }
-
- /**
- * Set the response of user to the confirmation dialog
- *
- * @param confirmed
- */
- public void setConfirmed(Boolean confirmed) {
- this.confirmed = confirmed;
- if (!confirmed.booleanValue()) {
- if (grammars.contains(categoryGrammar)) {
- grammars.remove(categoryGrammar);
- grammars.add(mainGrammar);
- }
- canonicalizedValue = null;
- value = new AmazonMenuResult();
- }
- }
-
- /**
- * Custom validation
- *
- * @see BaseModel#validate(Object,boolean)
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
-
- AmazonMenuResult castValue = (AmazonMenuResult) newValue;
- castValue.setReadableValue((canonicalizedValue == null) ? utterance :
- (canonicalizedValue + " " + utterance));
- if (castValue.getGenre() != null && castValue.getCategory() == null) {
- if (setErrorCode) setErrorCode(ERR_NO_CATEGORY);
- grammars.remove(mainGrammar);
- grammars.add(categoryGrammar);
- return Boolean.FALSE;
- }
- if (castValue.getCategory() != null && castValue.getGenre() == null) {
- castValue.setGenre(AmazonMenuResult.DEFAULT_GENRE);
- }
- return Boolean.TRUE;
- }
-
- /**
- * Class that encapsulates the user's choice from the main menu.
- *
- * @author Rahul Akolkar
- */
- public static class AmazonMenuResult implements Serializable {
- public static String SI_GENRE = "genre";
- public static String SI_CATEGORY = "category";
- public static String DEFAULT_GENRE = "301668";
- private String genre;
- private String category;
- private String readableValue;
-
- public AmazonMenuResult() {
- genre = null;
- category = null;
- readableValue = null;
- }
- public String getCategory() {
- return category;
- }
- public String getGenre() {
- return genre;
- }
- public String getReadableValue() {
- return readableValue;
- }
- public void setCategory(String string) {
- category = string;
- }
- public void setGenre(String string) {
- genre = string;
- }
- public void setReadableValue(String string) {
- readableValue = string;
- }
- public String toString() {
- return readableValue;
- }
- }
+ /**A constant for Error Code stating no category from the menu
+ * has been specified */
+ public static final int ERR_NO_CATEGORY = 1;
+ public final int getERR_NO_CATEGORY() { return ERR_NO_CATEGORY; }
+
+ // Component Grammars
+ private Grammar mainGrammar;
+ private Grammar categoryGrammar;
+ public void setMainGrammar(Grammar g) { mainGrammar = g; }
+ public void setCategoryGrammar(Grammar g) { categoryGrammar = g; }
+
+ /**
+ * Sets default values for all data members
+ */
+ public AmazonMenuTemplate() {
+ super();
+ this.value = new AmazonMenuResult();
+ this.mainGrammar = null;
+ this.categoryGrammar = null;
+ this.populateGrammars = true;
+ }
+
+ /**
+ * Sets the new value
+ *
+ * @see org.apache.taglibs.rdc.core.BaseModel.ValueInterpreter#setValueFromInterpretation()
+ */
+ public void setValueFromInterpretation() {
+ String genre = (String) interpretation.get(AmazonMenuResult.SI_GENRE);
+ String category = (String) interpretation.get(AmazonMenuResult.
+ SI_CATEGORY);
+ if (genre == null && category == null) {
+ value = baseCanonicalize((String)interpretation.get(Constants.
+ STR_EMPTY));
+ } else {
+ if (genre != null && genre.length() > 0) {
+ ((AmazonMenuResult) value).setGenre(genre);
+ }
+ if (category != null && category.length() > 0) {
+ ((AmazonMenuResult) value).setCategory(category);
+ }
+ }
+ setIsValid(baseValidate(value, true));
+
+ setCanonicalizedValue(((AmazonMenuResult) value).getReadableValue());
+ }
+
+ /**
+ * Initialize the component grammars for first round trip
+ *
+ * @see RDCTemplate#initComponentGrammars()
+ */
+ public void initComponentGrammars() {
+ // start with main grammar + initial if applicable
+ this.grammars.remove(categoryGrammar);
+ }
+
+ /**
+ * Set the response of user to the confirmation dialog
+ *
+ * @param confirmed
+ */
+ public void setConfirmed(Boolean confirmed) {
+ this.confirmed = confirmed;
+ if (!confirmed.booleanValue()) {
+ if (grammars.contains(categoryGrammar)) {
+ grammars.remove(categoryGrammar);
+ grammars.add(mainGrammar);
+ }
+ canonicalizedValue = null;
+ value = new AmazonMenuResult();
+ }
+ }
+
+ /**
+ * Custom validation
+ *
+ * @see BaseModel#validate(Object,boolean)
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+
+ AmazonMenuResult castValue = (AmazonMenuResult) newValue;
+ castValue.setReadableValue((canonicalizedValue == null) ? utterance :
+ (canonicalizedValue + " " + utterance));
+ if (castValue.getGenre() != null && castValue.getCategory() == null) {
+ if (setErrorCode) setErrorCode(ERR_NO_CATEGORY);
+ grammars.remove(mainGrammar);
+ grammars.add(categoryGrammar);
+ return Boolean.FALSE;
+ }
+ if (castValue.getCategory() != null && castValue.getGenre() == null) {
+ castValue.setGenre(AmazonMenuResult.DEFAULT_GENRE);
+ }
+ return Boolean.TRUE;
+ }
+
+ /**
+ * Class that encapsulates the user's choice from the main menu.
+ *
+ * @author Rahul Akolkar
+ */
+ public static class AmazonMenuResult implements Serializable {
+ public static String SI_GENRE = "genre";
+ public static String SI_CATEGORY = "category";
+ public static String DEFAULT_GENRE = "301668";
+ private String genre;
+ private String category;
+ private String readableValue;
+
+ public AmazonMenuResult() {
+ genre = null;
+ category = null;
+ readableValue = null;
+ }
+ public String getCategory() {
+ return category;
+ }
+ public String getGenre() {
+ return genre;
+ }
+ public String getReadableValue() {
+ return readableValue;
+ }
+ public void setCategory(String string) {
+ category = string;
+ }
+ public void setGenre(String string) {
+ genre = string;
+ }
+ public void setReadableValue(String string) {
+ readableValue = string;
+ }
+ public String toString() {
+ return readableValue;
+ }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/HTMLMenuLinks.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/HTMLMenuLinks.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/HTMLMenuLinks.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/HTMLMenuLinks.java Wed Aug 10 14:10:59 2005
@@ -32,112 +32,112 @@
*/
public class HTMLMenuLinks {
- static public String MAINMENU_CATEGORY = "mainmenu.category.";
- static public String MAINMENU_GENRE = "mainmenu.genre.";
- static public String DEFAULT_GENRE = "301668";
+ static public String MAINMENU_CATEGORY = "mainmenu.category.";
+ static public String MAINMENU_GENRE = "mainmenu.genre.";
+ static public String DEFAULT_GENRE = "301668";
static public String MUSICSTORE_PATH = "/musicstore-app";
-
- protected ResourceBundle menuRes = null;
- private String baseURL = null;
- private String links = "";
- private List categoryKeys = new ArrayList();
- private List genreKeys = new ArrayList();
-
-
- public HTMLMenuLinks(String aURL) {
+
+ protected ResourceBundle menuRes = null;
+ private String baseURL = null;
+ private String links = "";
+ private List categoryKeys = new ArrayList();
+ private List genreKeys = new ArrayList();
+
+
+ public HTMLMenuLinks(String aURL) {
menuRes = ResourceBundle.getBundle(
"org.apache.taglibs.rdc.sampleapps.musicstore.resources.MusicStoreMenu", Locale.US);
baseURL = aURL;
- Enumeration keys = menuRes.getKeys();
-
- while (keys.hasMoreElements()) {
- String akey = (String)keys.nextElement();
- String id = akey.substring(akey.lastIndexOf('.') + 1);
-
- if (akey.startsWith(MAINMENU_CATEGORY)) {
- categoryKeys.add(id);
- } else if (akey.startsWith(MAINMENU_GENRE)) {
- genreKeys.add(id);
- }
- }
- }
+ Enumeration keys = menuRes.getKeys();
+
+ while (keys.hasMoreElements()) {
+ String akey = (String)keys.nextElement();
+ String id = akey.substring(akey.lastIndexOf('.') + 1);
+
+ if (akey.startsWith(MAINMENU_CATEGORY)) {
+ categoryKeys.add(id);
+ } else if (akey.startsWith(MAINMENU_GENRE)) {
+ genreKeys.add(id);
+ }
+ }
+ }
- /**
- * Sets the value of the hints property.
- * @param aHints the new value of the hints property
- */
- public void generateGenreLinks() {
- links ="";
-
- for (int i = 0; i < genreKeys.size(); i++) {
- String key = (String)genreKeys.get(i);
- String linkURL = baseURL;
- String text = menuRes.getString(MAINMENU_GENRE + key);
-
- linkURL += MUSICSTORE_PATH + "/mainmenu_gui.do?genre=" + key;
- links += buildLinkNL(linkURL, text);
- }
- }
-
- public void generateCategoryLinks(String genre, boolean bBrowse) {
- links = "";
-
- for (int i = 0; i < categoryKeys.size(); i++) {
- String key = (String)categoryKeys.get(i);
- String linkURL = baseURL;
- String text = menuRes.getString(MAINMENU_CATEGORY + key);
-
- if (key.equals("0")) {
- if (bBrowse) {
- linkURL += MUSICSTORE_PATH + "/mainmenu_gui.do?browseMusic=1";
- links += buildLinkNL(linkURL, text);
- }
- } else {
- linkURL += "/listalbums_gui.do?category=" + key + "&genre=" + genre;
- links += buildLinkNL(linkURL, text);
- }
- }
- }
+ /**
+ * Sets the value of the hints property.
+ * @param aHints the new value of the hints property
+ */
+ public void generateGenreLinks() {
+ links ="";
+
+ for (int i = 0; i < genreKeys.size(); i++) {
+ String key = (String)genreKeys.get(i);
+ String linkURL = baseURL;
+ String text = menuRes.getString(MAINMENU_GENRE + key);
+
+ linkURL += MUSICSTORE_PATH + "/mainmenu_gui.do?genre=" + key;
+ links += buildLinkNL(linkURL, text);
+ }
+ }
+
+ public void generateCategoryLinks(String genre, boolean bBrowse) {
+ links = "";
+
+ for (int i = 0; i < categoryKeys.size(); i++) {
+ String key = (String)categoryKeys.get(i);
+ String linkURL = baseURL;
+ String text = menuRes.getString(MAINMENU_CATEGORY + key);
+
+ if (key.equals("0")) {
+ if (bBrowse) {
+ linkURL += MUSICSTORE_PATH + "/mainmenu_gui.do?browseMusic=1";
+ links += buildLinkNL(linkURL, text);
+ }
+ } else {
+ linkURL += "/listalbums_gui.do?category=" + key + "&genre=" + genre;
+ links += buildLinkNL(linkURL, text);
+ }
+ }
+ }
- public void generateAlbumLinks(MusicAlbum[] albums) {
- links = "";
-
- for (int i = 0; i < albums.length; i++) {
- MusicAlbum album = albums[i];
- String linkURL = baseURL + "/reviewalbum_gui.do?asin=" + album.getASIN();
- String text = album.getTitle() + ", " + album.getArtist();
- links += buildLinkNL(linkURL, text);
- }
- }
-
- public String getLinks() {
- return links;
- }
-
- public String getHomeLink() {
- String linkURL = baseURL + MUSICSTORE_PATH + "/mainmenu_gui.do";
- return buildLink(linkURL, "Home");
- }
+ public void generateAlbumLinks(MusicAlbum[] albums) {
+ links = "";
+
+ for (int i = 0; i < albums.length; i++) {
+ MusicAlbum album = albums[i];
+ String linkURL = baseURL + "/reviewalbum_gui.do?asin=" + album.getASIN();
+ String text = album.getTitle() + ", " + album.getArtist();
+ links += buildLinkNL(linkURL, text);
+ }
+ }
+
+ public String getLinks() {
+ return links;
+ }
+
+ public String getHomeLink() {
+ String linkURL = baseURL + MUSICSTORE_PATH + "/mainmenu_gui.do";
+ return buildLink(linkURL, "Home");
+ }
- public String getCartLink() {
- String linkURL = baseURL + "/viewcart_gui.do";
- return buildLink(linkURL, "View Cart");
- }
- public String getHelpLink() {
- String linkURL = baseURL + "/help_gui.do";
- return buildLink(linkURL, "About");
- }
-
- private String buildLinkNL(String link, String text) {
- return buildLink(link, text) + "<br/>";
- }
-
- private String buildLink(String link, String text) {
- MessageFormat format =
- new MessageFormat("<a href=\"{0}\">{1}</a>\n");
- Object[] args = {link, text};
- return format.format(args);
- }
-
+ public String getCartLink() {
+ String linkURL = baseURL + "/viewcart_gui.do";
+ return buildLink(linkURL, "View Cart");
+ }
+ public String getHelpLink() {
+ String linkURL = baseURL + "/help_gui.do";
+ return buildLink(linkURL, "About");
+ }
+
+ private String buildLinkNL(String link, String text) {
+ return buildLink(link, text) + "<br/>";
+ }
+
+ private String buildLink(String link, String text) {
+ MessageFormat format =
+ new MessageFormat("<a href=\"{0}\">{1}</a>\n");
+ Object[] args = {link, text};
+ return format.format(args);
+ }
+
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/MusicStoreAppBean.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/MusicStoreAppBean.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/MusicStoreAppBean.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/MusicStoreAppBean.java Wed Aug 10 14:10:59 2005
@@ -30,325 +30,325 @@
*/
public class MusicStoreAppBean {
- /**
- * The key used to save application state in the HttpSession
- */
- public static final String SESSION_KEY = "msAppBean";
- public String getSESSION_KEY() { return SESSION_KEY; }
-
- /**
- * The genre and category options selected by the user from the
- * main menu
- */
- private AmazonMenuTemplate.AmazonMenuResult menuResult;
-
- /**
- * The list of albums that are the result set of the user's current
- * query
- */
- private MusicAlbum[] albums;
-
- /**
- * The options that will be consumed by the <rdc:select1%gt; to play
- * out the result set of the user's current query
- */
- private SelectOne.Options options;
-
- /**
- * The readable value corresponding to the user's current query which
- * can be played out in a VXML prompt
- */
- private String choice;
-
- /**
- * The individual music album that is user has currently selected for
- * further operations
- */
- private MusicAlbum currentAlbum;
-
- /**
- * The amazon web services shopping cart object for this HttpSession
- */
- private Cart cart;
-
- /**
- * Store error prompt, which will be used by the error page
- */
- private String errorDescription;
-
- /**
- * The proactive help bean for this HttpSession, which will prompt user
- * with helpful hints using some "degree of annoyance%quot; criteria.
- */
- private ProactiveHelp proactiveHelp;
-
- /**
- * The MusicStore class instance for this HttpSession.
- */
- private MusicStore musicStore;
-
- /**
- * The final prompt that informs the user how to retrieve the shopping cart
- * that was assembled in this session. Coincides with the 'checkout' phase.
- */
- private String checkoutPrompt;
-
- /**
- * The HTMLMenuLinks class instance for this HttpSession.
- */
- private HTMLMenuLinks menuLinks;
-
- /**
- * Store channel information of the application, The application could
- * either be a GUI application, a VOICE application or a VOICE Debug
- * applicaton which allows you to output the VXML to a Visual Browser.
- */
- private String channel;
-
- /**
- * GUI channel
- */
- public static final String GUI_APP = "msGUI";
- /**
- * Voice channel
- */
- public static final String VOICE_APP = "msVOICE";
- /**
- * Voice Debug channel
- */
- public static final String VOICE_DBG = "msVOICEDBG";
-
-
- /**
- * MusicStoreAppBean Constructor
- */
- public MusicStoreAppBean(String subscriptionId) {
- this.menuResult = null;
- this.albums = null;
- this.options = null;
- this.choice = null;
- this.currentAlbum = null;
- this.cart = null;
- this.errorDescription = null;
- this.proactiveHelp = null;
- this.musicStore = new MusicStore(subscriptionId);
- this.checkoutPrompt = null;
- this.channel = null;
- this.menuLinks = null;
- }
-
- /**
- * Get the user's main menu selection
- *
- * @return the AmazonMenuTemplate.AmazonMenuResult object
- * corresponding to the main menu selection
- */
- public AmazonMenuTemplate.AmazonMenuResult getMenuResult() {
- return menuResult;
- }
-
- /**
- * Get the array of albums that are the result set of the user's current
- * query
- *
- * @return The array of albums that are the result set of the user's current
- * query
- */
- public MusicAlbum[] getAlbums() {
- return albums;
- }
-
- /**
- * Get the readable query string
- *
- * @return choice the readable query string
- */
- public String getChoice() {
- return choice;
- }
-
- /**
- * Get the result set of the user's query as <rdc:select1> options
- *
- * @return options the SelectOne.Options object
- */
- public SelectOne.Options getOptions() {
- return options;
- }
-
- /**
- * Get the album the user is currently interacting with
- *
- * @return currentAlbum the MusicAlbum the user is currently
- * interacting with
- */
- public MusicAlbum getCurrentAlbum() {
- return currentAlbum;
- }
-
- /**
- * Get the shopping cart object for this session
- *
- * @return cart the shopping cart object
- */
- public Cart getCart() {
- return cart;
- }
-
- /**
- * Get the error description string
- *
- * @return errorDescription the error description string
- */
- public String getErrorDescription() {
- return errorDescription;
- }
-
- /**
- * Get the proactive help bean
- *
- * @return proactiveHelp the proactive help bean
- */
- public ProactiveHelp getProactiveHelp() {
- return proactiveHelp;
- }
-
- /**
- * Get the check out prompt
- *
- * @return checkoutPrompt the check out prompt
- */
- public String getCheckoutPrompt() {
- return checkoutPrompt;
- }
-
- /**
- * Get the music store object
- *
- * @return MusicStore The music store object
- */
- public MusicStore getMusicStore() {
- return musicStore;
- }
-
- /**
- * Get the menu links object
- *
- * @return HTMLMenuLinks The menu links object
- */
- public HTMLMenuLinks getMenuLinks() {
- return menuLinks;
- }
-
- /**
- * Get the application channel
- *
- * @return channel The channel key
- */
- public String getChannel() {
- return channel;
- }
-
- /**
- * Set the user's main menu selection data
- *
- * @param menuResult the AmazonMenuTemplate.AmazonMenuResult object
- * corresponding to the main menu selection
- */
- public void setMenuResult(AmazonMenuTemplate.AmazonMenuResult menuResult) {
- this.menuResult = menuResult;
- }
-
- /**
- * Set the result set of the user's current query
- *
- * @param albums The array of albums that are the result set of the
- * user's current query
- */
- public void setAlbums(MusicAlbum[] albums) {
- this.albums = albums;
- }
-
- /**
- * Set the readable query string
- *
- * @param choice the readable query string
- */
- public void setChoice(String choice) {
- this.choice = choice;
- }
-
- /**
- * Set the result set of the user's query as <rdc:select1> options
- *
- * @param options the SelectOne.Options object
- */
- public void setOptions(SelectOne.Options options) {
- this.options = options;
- }
-
- /**
- * Set the album the user is currently interacting with
- *
- * @param currentAlbum the MusicAlbum the user is currently
- * interacting with
- */
- public void setCurrentAlbum(MusicAlbum currentAlbum) {
- this.currentAlbum = currentAlbum;
- }
-
- /**
- * Set the shopping cart object for this session
- *
- * @param cart the shopping cart object
- */
- public void setCart(Cart cart) {
- this.cart = cart;
- }
-
- /**
- * Set the error description string
- *
- * @param errorDescription the error description string
- */
- public void setErrorDescription(String errorDescription) {
- this.errorDescription = errorDescription;
- }
-
- /**
- * Set the proactive help bean for this session
- *
- * @param proactiveHelp the proactive help bean
- */
- public void setProactiveHelp(ProactiveHelp proactiveHelp) {
- this.proactiveHelp = proactiveHelp;
- }
-
- /**
- * Set the check out prompt
- *
- * @param checkoutPrompt the check out prompt
- */
- public void setCheckoutPrompt(String checkoutPrompt) {
- this.checkoutPrompt = checkoutPrompt;
- }
-
- /**
- * Set the menuLinks bean for Links generation
- *
- * @param menuLinks The menuLinks to set.
- */
- public void setMenuLinks(HTMLMenuLinks menuLinks) {
- this.menuLinks = menuLinks;
- }
-
- /**
- * Set the channel of the application
- *
- * @param channel the application channel
- */
- public void setChannel(String channel) {
- this.channel = channel;
- }
+ /**
+ * The key used to save application state in the HttpSession
+ */
+ public static final String SESSION_KEY = "msAppBean";
+ public String getSESSION_KEY() { return SESSION_KEY; }
+
+ /**
+ * The genre and category options selected by the user from the
+ * main menu
+ */
+ private AmazonMenuTemplate.AmazonMenuResult menuResult;
+
+ /**
+ * The list of albums that are the result set of the user's current
+ * query
+ */
+ private MusicAlbum[] albums;
+
+ /**
+ * The options that will be consumed by the <rdc:select1%gt; to play
+ * out the result set of the user's current query
+ */
+ private SelectOne.Options options;
+
+ /**
+ * The readable value corresponding to the user's current query which
+ * can be played out in a VXML prompt
+ */
+ private String choice;
+
+ /**
+ * The individual music album that is user has currently selected for
+ * further operations
+ */
+ private MusicAlbum currentAlbum;
+
+ /**
+ * The amazon web services shopping cart object for this HttpSession
+ */
+ private Cart cart;
+
+ /**
+ * Store error prompt, which will be used by the error page
+ */
+ private String errorDescription;
+
+ /**
+ * The proactive help bean for this HttpSession, which will prompt user
+ * with helpful hints using some "degree of annoyance%quot; criteria.
+ */
+ private ProactiveHelp proactiveHelp;
+
+ /**
+ * The MusicStore class instance for this HttpSession.
+ */
+ private MusicStore musicStore;
+
+ /**
+ * The final prompt that informs the user how to retrieve the shopping cart
+ * that was assembled in this session. Coincides with the 'checkout' phase.
+ */
+ private String checkoutPrompt;
+
+ /**
+ * The HTMLMenuLinks class instance for this HttpSession.
+ */
+ private HTMLMenuLinks menuLinks;
+
+ /**
+ * Store channel information of the application, The application could
+ * either be a GUI application, a VOICE application or a VOICE Debug
+ * applicaton which allows you to output the VXML to a Visual Browser.
+ */
+ private String channel;
+
+ /**
+ * GUI channel
+ */
+ public static final String GUI_APP = "msGUI";
+ /**
+ * Voice channel
+ */
+ public static final String VOICE_APP = "msVOICE";
+ /**
+ * Voice Debug channel
+ */
+ public static final String VOICE_DBG = "msVOICEDBG";
+
+
+ /**
+ * MusicStoreAppBean Constructor
+ */
+ public MusicStoreAppBean(String subscriptionId) {
+ this.menuResult = null;
+ this.albums = null;
+ this.options = null;
+ this.choice = null;
+ this.currentAlbum = null;
+ this.cart = null;
+ this.errorDescription = null;
+ this.proactiveHelp = null;
+ this.musicStore = new MusicStore(subscriptionId);
+ this.checkoutPrompt = null;
+ this.channel = null;
+ this.menuLinks = null;
+ }
+
+ /**
+ * Get the user's main menu selection
+ *
+ * @return the AmazonMenuTemplate.AmazonMenuResult object
+ * corresponding to the main menu selection
+ */
+ public AmazonMenuTemplate.AmazonMenuResult getMenuResult() {
+ return menuResult;
+ }
+
+ /**
+ * Get the array of albums that are the result set of the user's current
+ * query
+ *
+ * @return The array of albums that are the result set of the user's current
+ * query
+ */
+ public MusicAlbum[] getAlbums() {
+ return albums;
+ }
+
+ /**
+ * Get the readable query string
+ *
+ * @return choice the readable query string
+ */
+ public String getChoice() {
+ return choice;
+ }
+
+ /**
+ * Get the result set of the user's query as <rdc:select1> options
+ *
+ * @return options the SelectOne.Options object
+ */
+ public SelectOne.Options getOptions() {
+ return options;
+ }
+
+ /**
+ * Get the album the user is currently interacting with
+ *
+ * @return currentAlbum the MusicAlbum the user is currently
+ * interacting with
+ */
+ public MusicAlbum getCurrentAlbum() {
+ return currentAlbum;
+ }
+
+ /**
+ * Get the shopping cart object for this session
+ *
+ * @return cart the shopping cart object
+ */
+ public Cart getCart() {
+ return cart;
+ }
+
+ /**
+ * Get the error description string
+ *
+ * @return errorDescription the error description string
+ */
+ public String getErrorDescription() {
+ return errorDescription;
+ }
+
+ /**
+ * Get the proactive help bean
+ *
+ * @return proactiveHelp the proactive help bean
+ */
+ public ProactiveHelp getProactiveHelp() {
+ return proactiveHelp;
+ }
+
+ /**
+ * Get the check out prompt
+ *
+ * @return checkoutPrompt the check out prompt
+ */
+ public String getCheckoutPrompt() {
+ return checkoutPrompt;
+ }
+
+ /**
+ * Get the music store object
+ *
+ * @return MusicStore The music store object
+ */
+ public MusicStore getMusicStore() {
+ return musicStore;
+ }
+
+ /**
+ * Get the menu links object
+ *
+ * @return HTMLMenuLinks The menu links object
+ */
+ public HTMLMenuLinks getMenuLinks() {
+ return menuLinks;
+ }
+
+ /**
+ * Get the application channel
+ *
+ * @return channel The channel key
+ */
+ public String getChannel() {
+ return channel;
+ }
+
+ /**
+ * Set the user's main menu selection data
+ *
+ * @param menuResult the AmazonMenuTemplate.AmazonMenuResult object
+ * corresponding to the main menu selection
+ */
+ public void setMenuResult(AmazonMenuTemplate.AmazonMenuResult menuResult) {
+ this.menuResult = menuResult;
+ }
+
+ /**
+ * Set the result set of the user's current query
+ *
+ * @param albums The array of albums that are the result set of the
+ * user's current query
+ */
+ public void setAlbums(MusicAlbum[] albums) {
+ this.albums = albums;
+ }
+
+ /**
+ * Set the readable query string
+ *
+ * @param choice the readable query string
+ */
+ public void setChoice(String choice) {
+ this.choice = choice;
+ }
+
+ /**
+ * Set the result set of the user's query as <rdc:select1> options
+ *
+ * @param options the SelectOne.Options object
+ */
+ public void setOptions(SelectOne.Options options) {
+ this.options = options;
+ }
+
+ /**
+ * Set the album the user is currently interacting with
+ *
+ * @param currentAlbum the MusicAlbum the user is currently
+ * interacting with
+ */
+ public void setCurrentAlbum(MusicAlbum currentAlbum) {
+ this.currentAlbum = currentAlbum;
+ }
+
+ /**
+ * Set the shopping cart object for this session
+ *
+ * @param cart the shopping cart object
+ */
+ public void setCart(Cart cart) {
+ this.cart = cart;
+ }
+
+ /**
+ * Set the error description string
+ *
+ * @param errorDescription the error description string
+ */
+ public void setErrorDescription(String errorDescription) {
+ this.errorDescription = errorDescription;
+ }
+
+ /**
+ * Set the proactive help bean for this session
+ *
+ * @param proactiveHelp the proactive help bean
+ */
+ public void setProactiveHelp(ProactiveHelp proactiveHelp) {
+ this.proactiveHelp = proactiveHelp;
+ }
+
+ /**
+ * Set the check out prompt
+ *
+ * @param checkoutPrompt the check out prompt
+ */
+ public void setCheckoutPrompt(String checkoutPrompt) {
+ this.checkoutPrompt = checkoutPrompt;
+ }
+
+ /**
+ * Set the menuLinks bean for Links generation
+ *
+ * @param menuLinks The menuLinks to set.
+ */
+ public void setMenuLinks(HTMLMenuLinks menuLinks) {
+ this.menuLinks = menuLinks;
+ }
+
+ /**
+ * Set the channel of the application
+ *
+ * @param channel the application channel
+ */
+ public void setChannel(String channel) {
+ this.channel = channel;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ProactiveHelp.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ProactiveHelp.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ProactiveHelp.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ProactiveHelp.java Wed Aug 10 14:10:59 2005
@@ -106,9 +106,9 @@
default:
int guess = generator.nextInt(100);
if(guess >= threshold)
- return false;
+ return false;
else
- return true;
+ return true;
}
}
@@ -121,14 +121,14 @@
if(usageWeighted) {
int leftNB;
if(hintIdx == 0)
- leftNB = sz - 1;
+ leftNB = sz - 1;
else
- leftNB = hintIdx - 1;
+ leftNB = hintIdx - 1;
int rightNB = (hintIdx+1)%sz;
//check if hintIdx is over-used
if(stats[hintIdx] >= (stats[leftNB] + stats[rightNB])/2) {
- //equalization
- hintIdx = (stats[leftNB] > stats[rightNB]) ? rightNB : leftNB;
+ //equalization
+ hintIdx = (stats[leftNB] > stats[rightNB]) ? rightNB : leftNB;
}
}
stats[hintIdx]++;
@@ -170,12 +170,12 @@
stats = null;
Enumeration keys = hints.getKeys();
while(keys.hasMoreElements()) {
- Object akey = keys.nextElement();
- allkeys.add(akey);
+ Object akey = keys.nextElement();
+ allkeys.add(akey);
}
stats = new int[allkeys.size()];
for(int i=0; i<stats.length; i++) {
- stats[i] = 0;
+ stats[i] = 0;
}
}
}
@@ -189,19 +189,19 @@
throw new IllegalStateException("Hints is an empty collection, can not apply usage statistics!");
} else {
for(int i=0; i<allkeys.size(); i++) {
- String akey = (String)allkeys.get(i);
- //we should handle both Integer and String
- Object count = sts.get(akey);
- if(count == null) {
- continue;
- } else if(count instanceof Integer) {
- stats[i] = ((Integer)count).intValue();
- } else if(count instanceof String) {
- stats[i] = Integer.parseInt((String)count);
- } else {
- throw new IllegalArgumentException(count.getClass().getName() +
- " can not serve as usage count");
- }
+ String akey = (String)allkeys.get(i);
+ //we should handle both Integer and String
+ Object count = sts.get(akey);
+ if(count == null) {
+ continue;
+ } else if(count instanceof Integer) {
+ stats[i] = ((Integer)count).intValue();
+ } else if(count instanceof String) {
+ stats[i] = Integer.parseInt((String)count);
+ } else {
+ throw new IllegalArgumentException(count.getClass().getName() +
+ " can not serve as usage count");
+ }
}
}
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ReviewAlbumTemplate.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ReviewAlbumTemplate.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ReviewAlbumTemplate.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/ReviewAlbumTemplate.java Wed Aug 10 14:10:59 2005
@@ -29,30 +29,30 @@
*/
public class ReviewAlbumTemplate extends RDCTemplate {
- /**A constant for Error Code stating album details should
- * be played out */
- public static final int ERR_NEED_DETAILS = 1;
- public final int getERR_NEED_DETAILS() { return ERR_NEED_DETAILS; }
+ /**A constant for Error Code stating album details should
+ * be played out */
+ public static final int ERR_NEED_DETAILS = 1;
+ public final int getERR_NEED_DETAILS() { return ERR_NEED_DETAILS; }
- /**
- * Sets default values for all data members
- */
- public ReviewAlbumTemplate() {
- super();
- }
+ /**
+ * Sets default values for all data members
+ */
+ public ReviewAlbumTemplate() {
+ super();
+ }
- /**
- * Custom validation
- *
- * @see org.apache.taglibs.rdc.core.BaseModel#validate(Object,boolean)
- */
- protected Boolean validate(Object newValue, boolean setErrorCode) {
- if (newValue.equals("details")) {
- if (setErrorCode) setErrorCode(ERR_NEED_DETAILS);
- return Boolean.FALSE;
- }
- return Boolean.TRUE;
- }
+ /**
+ * Custom validation
+ *
+ * @see org.apache.taglibs.rdc.core.BaseModel#validate(Object,boolean)
+ */
+ protected Boolean validate(Object newValue, boolean setErrorCode) {
+ if (newValue.equals("details")) {
+ if (setErrorCode) setErrorCode(ERR_NEED_DETAILS);
+ return Boolean.FALSE;
+ }
+ return Boolean.TRUE;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AddToCartAction.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AddToCartAction.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AddToCartAction.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AddToCartAction.java Wed Aug 10 14:10:59 2005
@@ -49,8 +49,8 @@
throws Exception {
HttpSession session = request.getSession();
- MusicStoreAppBean msBean = (MusicStoreAppBean) session.
- getAttribute(MusicStoreAppBean.SESSION_KEY);
+ MusicStoreAppBean msBean = (MusicStoreAppBean) session.
+ getAttribute(MusicStoreAppBean.SESSION_KEY);
MusicStore ms = msBean.getMusicStore();
Cart currentCart = msBean.getCart();
MusicAlbum currentAlbum = msBean.getCurrentAlbum();
@@ -62,20 +62,20 @@
currentCart = ms.createCart(currentAlbum, 1);
}
}
- //cleanup session from RDCs
- session.removeAttribute("dialogMap");
-
+ //cleanup session from RDCs
+ session.removeAttribute("dialogMap");
+
if (currentAlbum == null || currentCart == null) {
msBean.setErrorDescription("Failed to add album to your " +
- "shopping cart. please try again.");
+ "shopping cart. please try again.");
return mapping.findForward("onerror");
}
msBean.setCart(currentCart);
String title = currentAlbum.getTitle();
request.setAttribute("promptContent", "Added " + title +
- " to the shopping cart.");
- return mapping.findForward("OK");
+ " to the shopping cart.");
+ return mapping.findForward("OK");
}
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AlbumFilterForm.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AlbumFilterForm.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AlbumFilterForm.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/AlbumFilterForm.java Wed Aug 10 14:10:59 2005
@@ -32,24 +32,24 @@
*/
public class AlbumFilterForm extends ActionForm {
- private AmazonMenuTemplate.AmazonMenuResult choice;
+ private AmazonMenuTemplate.AmazonMenuResult choice;
private String genre;
private String category;
- public AlbumFilterForm() {
- choice = null;
+ public AlbumFilterForm() {
+ choice = null;
genre = null;
category = null;
- }
+ }
- public AmazonMenuTemplate.AmazonMenuResult getChoice() {
- return choice;
- }
+ public AmazonMenuTemplate.AmazonMenuResult getChoice() {
+ return choice;
+ }
- public void setChoice(AmazonMenuTemplate.AmazonMenuResult result) {
- choice = result;
- }
-
+ public void setChoice(AmazonMenuTemplate.AmazonMenuResult result) {
+ choice = result;
+ }
+
/**
* Access method for the genre property.
*
@@ -85,10 +85,10 @@
public void setCategory(String aCategory) {
category = aCategory;
}
-
- public ActionErrors validate(ActionMapping mapping,
- HttpServletRequest request) {
- ActionErrors errors = new ActionErrors();
+
+ public ActionErrors validate(ActionMapping mapping,
+ HttpServletRequest request) {
+ ActionErrors errors = new ActionErrors();
if (category != null && genre != null) {
// canonicalize choice from GUI
@@ -99,7 +99,7 @@
StrutsSubmitTag.populate(this, request, errors);
}
- return errors;
- }
+ return errors;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutAction.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutAction.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutAction.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutAction.java Wed Aug 10 14:10:59 2005
@@ -38,104 +38,104 @@
* @author Rahul Akolkar
*/
public class CheckoutAction extends Action {
-
- public CheckoutAction() {
- super();
- }
+
+ public CheckoutAction() {
+ super();
+ }
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ public ActionForward execute(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
- HttpSession session = request.getSession();
- MusicStoreAppBean msBean = (MusicStoreAppBean) session.
- getAttribute(MusicStoreAppBean.SESSION_KEY);
- CheckoutForm coForm = (CheckoutForm) form;
- String action = coForm.getAction();
- Cart currentCart = msBean.getCart();
+ HttpSession session = request.getSession();
+ MusicStoreAppBean msBean = (MusicStoreAppBean) session.
+ getAttribute(MusicStoreAppBean.SESSION_KEY);
+ CheckoutForm coForm = (CheckoutForm) form;
+ String action = coForm.getAction();
+ Cart currentCart = msBean.getCart();
- if (currentCart == null && !action.equals("shopping")) {
- msBean.setErrorDescription("Shopping cart is empty or " +
- "cart not found.");
- return mapping.findForward("onerror");
- }
+ if (currentCart == null && !action.equals("shopping")) {
+ msBean.setErrorDescription("Shopping cart is empty or " +
+ "cart not found.");
+ return mapping.findForward("onerror");
+ }
- // Voice specified calls
- if (msBean.getChannel() == MusicStoreAppBean.VOICE_APP ||
- msBean.getChannel() == MusicStoreAppBean.VOICE_DBG ) {
-
- //cleanup session from RDCs
- session.removeAttribute("dialogMap");
+ // Voice specified calls
+ if (msBean.getChannel() == MusicStoreAppBean.VOICE_APP ||
+ msBean.getChannel() == MusicStoreAppBean.VOICE_DBG ) {
+
+ //cleanup session from RDCs
+ session.removeAttribute("dialogMap");
- if (action.equals("checkout")) {
- String hostURI = getHostAsPrompt(request.getServerName());
- int port = request.getServerPort();
- if (80 != port && 0 != port && 443 != port) {
- hostURI += " colon " + Integer.toString(port, 10) ;
- }
- String prompt = createCartLink(session, currentCart, hostURI);
- msBean.setCheckoutPrompt(prompt);
- } else if (action.equals("viewcart")) {
- StringBuffer prompt = new StringBuffer("These following titles " +
- "are in your cart. ");
- CartItem[] items = currentCart.getCartItems();
- for (int i = 0; i < items.length; i++) {
- prompt.append(items[i].getTitle()).append(", ");
- }
- request.setAttribute("promptContent", prompt.toString());
- }
- }
+ if (action.equals("checkout")) {
+ String hostURI = getHostAsPrompt(request.getServerName());
+ int port = request.getServerPort();
+ if (80 != port && 0 != port && 443 != port) {
+ hostURI += " colon " + Integer.toString(port, 10) ;
+ }
+ String prompt = createCartLink(session, currentCart, hostURI);
+ msBean.setCheckoutPrompt(prompt);
+ } else if (action.equals("viewcart")) {
+ StringBuffer prompt = new StringBuffer("These following titles " +
+ "are in your cart. ");
+ CartItem[] items = currentCart.getCartItems();
+ for (int i = 0; i < items.length; i++) {
+ prompt.append(items[i].getTitle()).append(", ");
+ }
+ request.setAttribute("promptContent", prompt.toString());
+ }
+ }
- if (action.equals("checkout")) {
- return mapping.findForward("goodbye");
- } else if (action.equals("viewcart")) {
- return mapping.findForward("viewcart");
- } else if (action.equals("shopping")) {
- return mapping.findForward("continueshop");
- } else {
- msBean.setErrorDescription("Error, unknown checkout action.");
- return mapping.findForward("onerror");
- }
- }
-
- private String getHostAsPrompt(String hostURI) {
- // Well, we tried ;-)
- if (hostURI.trim().equalsIgnoreCase("localhost")) {
- return " local host ";
- } else if (hostURI.indexOf('.') != -1){
- return hostURI.replaceAll(".", " dot ");
- }
- return hostURI;
- }
+ if (action.equals("checkout")) {
+ return mapping.findForward("goodbye");
+ } else if (action.equals("viewcart")) {
+ return mapping.findForward("viewcart");
+ } else if (action.equals("shopping")) {
+ return mapping.findForward("continueshop");
+ } else {
+ msBean.setErrorDescription("Error, unknown checkout action.");
+ return mapping.findForward("onerror");
+ }
+ }
+
+ private String getHostAsPrompt(String hostURI) {
+ // Well, we tried ;-)
+ if (hostURI.trim().equalsIgnoreCase("localhost")) {
+ return " local host ";
+ } else if (hostURI.indexOf('.') != -1){
+ return hostURI.replaceAll(".", " dot ");
+ }
+ return hostURI;
+ }
- private String createCartLink(HttpSession session, Cart cart, String hostURI) {
+ private String createCartLink(HttpSession session, Cart cart, String hostURI) {
- final String NEXTCARTID = "application_NextCartID";
- final String CART_PREFIX = "msCart";
- ServletContext context = session.getServletContext();
- Integer cartID = (Integer)context.getAttribute(NEXTCARTID);
- Integer nextId = null;
+ final String NEXTCARTID = "application_NextCartID";
+ final String CART_PREFIX = "msCart";
+ ServletContext context = session.getServletContext();
+ Integer cartID = (Integer)context.getAttribute(NEXTCARTID);
+ Integer nextId = null;
+
+ if (cartID == null) {
+ cartID = new Integer(1);
+ nextId = new Integer(2);
+ } else {
+ nextId = new Integer(cartID.intValue() + 1);
+ }
+ context.setAttribute(NEXTCARTID, nextId);
- if (cartID == null) {
- cartID = new Integer(1);
- nextId = new Integer(2);
- } else {
- nextId = new Integer(cartID.intValue() + 1);
- }
- context.setAttribute(NEXTCARTID, nextId);
-
- // save URL with cart ID
- context.setAttribute(CART_PREFIX + cartID, cart.getPurchaseURL());
- StringBuffer sb = new StringBuffer("Your cart number is ").append(cartID);
- sb.append("<break time=\"500ms\"/> To complete the checkout, ");
- sb.append("please go to this website <break time=\"500ms\"/>");
- sb.append("h t t p colon slash slash <break time=\"500ms\"/> ");
- sb.append(hostURI).append(" <break time=\"500ms\"/> ");
- sb.append("slash r d c <break time=\"500ms\"/>dash <break time=\"500ms\"/>");
- sb.append("examples <break time=\"500ms\"/>slash <break time=\"500ms\"/>");
- sb.append(" get cart dot j s p <break time=\"500ms\"/>and retrieve your cart ");
- sb.append("using cart number ").append(cartID);
- return sb.toString();
- }
+ // save URL with cart ID
+ context.setAttribute(CART_PREFIX + cartID, cart.getPurchaseURL());
+ StringBuffer sb = new StringBuffer("Your cart number is ").append(cartID);
+ sb.append("<break time=\"500ms\"/> To complete the checkout, ");
+ sb.append("please go to this website <break time=\"500ms\"/>");
+ sb.append("h t t p colon slash slash <break time=\"500ms\"/> ");
+ sb.append(hostURI).append(" <break time=\"500ms\"/> ");
+ sb.append("slash r d c <break time=\"500ms\"/>dash <break time=\"500ms\"/>");
+ sb.append("examples <break time=\"500ms\"/>slash <break time=\"500ms\"/>");
+ sb.append(" get cart dot j s p <break time=\"500ms\"/>and retrieve your cart ");
+ sb.append("using cart number ").append(cartID);
+ return sb.toString();
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutForm.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutForm.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutForm.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/CheckoutForm.java Wed Aug 10 14:10:59 2005
@@ -55,7 +55,7 @@
public ActionErrors validate(ActionMapping mapping,
- HttpServletRequest request) {
+ HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
//try block is to make this compatible with regular Struts submit
try {
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/IndividualAlbumForm.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/IndividualAlbumForm.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/IndividualAlbumForm.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/sampleapps/musicstore/struts/IndividualAlbumForm.java Wed Aug 10 14:10:59 2005
@@ -53,7 +53,7 @@
}
public ActionErrors validate(ActionMapping mapping,
- HttpServletRequest request) {
+ HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
//try block is to make this compatible with regular Struts submit
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org