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 [5/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/core/GroupConfirm.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupConfirm.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupConfirm.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupConfirm.java Wed Aug 10 14:10:59 2005
@@ -34,178 +34,178 @@
*/
public class GroupConfirm {
- // Error messages (to be i18n'zed)
- private static final String ERR_IO_FAILURE = "IO Exception while " +
- "processing confirmation for group";
-
- // Logging
- private static Log log = LogFactory.getLog(GroupConfirm.class);
-
- // CLASS PROPERTIES
- private GroupModel localModel = null;
- private String submit = null;
- private Map localMap = null;
- private PageContext ctx = null;
- private String idConfirm = null;
- private String idIdentify = null;
- private int confirmState;
-
- /* Constructor */
- public GroupConfirm(PageContext ctx, GroupModel localModel, String id) {
- this.localModel = localModel;
- this.submit = localModel.getSubmit();
- this.localMap = localModel.getLocalMap();
- this.ctx = ctx;
- this.idConfirm = id + "Confirm";
- this.idIdentify = id + "Identify";
- this.confirmState = Constants.CONF_STATE_INPUT;
- }
-
- /**
- * Group confirmation state machine
- *
- * @return int groupState
- */
- public int doGroupConfirmation() {
- if (confirmState == Constants.CONF_STATE_INPUT) {
- populateFieldConfirm();
- return confirmState;
- }
-
- if (confirmState == Constants.CONF_STATE_CONFIRMATION){
- compareConfirmationValues();
- return confirmState;
- }
-
- if (confirmState == Constants.CONF_STATE_IDENTIFICATION){
- compareIdentificationValues();
- return confirmState;
- }
-
- return Constants.CONF_STATE_UNEXPECTED;
- }
-
- private void populateFieldConfirm() {
-
- StringBuffer result = new StringBuffer();
- String current = null;
- BaseModel model = null;
-
- result.append("<field name = \"" + idConfirm + "\" type = \""
- + Constants.STR_BOOLEAN + "\">");
- result.append(Constants.VXML_PROMPT_BEGIN +
- Constants.STR_CONF_PROMPT_START +
- Constants.STR_CONF_PROMPT_ENUMERATE + Constants.VXML_PROMPT_END);
- result.append(Constants.VXML_PROMPT_BEGIN +
- Constants.STR_CONF_PROMPT_END + Constants.VXML_PROMPT_END);
-
- Iterator iter = localMap.keySet().iterator();
- while (iter.hasNext()) {
- current = (String) iter.next();
- if (!current.equals(Constants.STR_INIT_ONLY_FLAG)) {
- model = (BaseModel) localMap.get(current);
- result.append(Constants.VXML_OPTION_BEGIN);
- result.append(model.getCanonicalizedValue());
- result.append(Constants.VXML_OPTION_END);
- }
- }
- result.append("<filled> <submit next =\"" + submit + "\" namelist=\""
- + idConfirm + "\" /> </filled></field>");
- try {
- ctx.getOut().write(result.toString());
- } catch (IOException ioe) {
- log.error(ERR_IO_FAILURE);
- }
- confirmState = Constants.CONF_STATE_CONFIRMATION;
- }
-
- private void compareConfirmationValues() {
-
- String testConfirm = ctx.getRequest().getParameter(idConfirm);
- if (testConfirm == null) {
- confirmState = Constants.CONF_STATE_UNEXPECTED;
- return;
- }
-
- if (confirmState == Constants.CONF_STATE_CONFIRMATION) {
- if (testConfirm.equals(Constants.STR_TRUE)) {
- localModel.setConfirmed(Boolean.TRUE);
- confirmState = Constants.CONF_STATE_DONE;
- } else if (testConfirm.equals(Constants.STR_FALSE)) {
- populateFieldIdentification();
- }
- }
-
- }
-
- private void populateFieldIdentification() {
- StringBuffer result = new StringBuffer();
- String current = null;
- BaseModel model = null;
-
- result.append("<field name = \"" + idIdentify + "\">" +
- Constants.VXML_PROMPT_BEGIN + Constants.STR_CONF_PROMPT_SELECT +
- Constants.VXML_PROMPT_END);
-
- Iterator iter = localMap.keySet().iterator();
- while (iter.hasNext()) {
- current = (String) iter.next();
- if (!current.equals(Constants.STR_INIT_ONLY_FLAG)) {
- model = (BaseModel) localMap.get(current);
- if (model.getConfirmed() == Boolean.FALSE) {
- result.append(Constants.VXML_OPTION_BEGIN).append(current).
- append(Constants.VXML_OPTION_END);
- }
- }
- }
-
- result.append("<filled> <submit next =\"" + submit + "\" namelist=\""
- + idIdentify + "\" /></filled></field>");
- try {
- ctx.getOut().write(result.toString());
- } catch (IOException ioe) {
- log.error(ERR_IO_FAILURE);
- }
- confirmState = Constants.CONF_STATE_IDENTIFICATION;
-
- }
-
- private void compareIdentificationValues() {
-
- String testIdentify = ctx.getRequest().getParameter(idIdentify);
- if (testIdentify == null) {
- confirmState = Constants.CONF_STATE_UNEXPECTED;
- return;
- }
- BaseModel model = null;
- StringBuffer result = new StringBuffer();
- Iterator iter = localMap.keySet().iterator();
- String current = null;
- while (iter.hasNext()) {
- current = (String) iter.next();
- if (current.equals(Constants.STR_INIT_ONLY_FLAG)) {
- continue;
- }
- model = (BaseModel) localMap.get(current);
- if (confirmState == Constants.CONF_STATE_IDENTIFICATION) {
- if (testIdentify.equals(current)) {
- model.setConfirmed(Boolean.FALSE);
- model.setConfirm(Boolean.TRUE);
- model.setState(Constants.FSM_INPUT);
- model.setSkipSubmit(Boolean.FALSE);
- result.append(Constants.VXML_BLOCK_BEGIN + "OK, lets try " +
- model.getId() + " again.");
- result.append("<submit next =\"" + submit + "\" />");
- result.append(Constants.VXML_BLOCK_END);
- }
- }
- }
- try {
- ctx.getOut().write(result.toString());
- } catch (IOException ioe) {
- log.error(ERR_IO_FAILURE);
- }
- localModel.setState(Constants.GRP_STATE_RUNNING);
- confirmState = Constants.CONF_STATE_INPUT;
- }
+ // Error messages (to be i18n'zed)
+ private static final String ERR_IO_FAILURE = "IO Exception while " +
+ "processing confirmation for group";
+
+ // Logging
+ private static Log log = LogFactory.getLog(GroupConfirm.class);
+
+ // CLASS PROPERTIES
+ private GroupModel localModel = null;
+ private String submit = null;
+ private Map localMap = null;
+ private PageContext ctx = null;
+ private String idConfirm = null;
+ private String idIdentify = null;
+ private int confirmState;
+
+ /* Constructor */
+ public GroupConfirm(PageContext ctx, GroupModel localModel, String id) {
+ this.localModel = localModel;
+ this.submit = localModel.getSubmit();
+ this.localMap = localModel.getLocalMap();
+ this.ctx = ctx;
+ this.idConfirm = id + "Confirm";
+ this.idIdentify = id + "Identify";
+ this.confirmState = Constants.CONF_STATE_INPUT;
+ }
+
+ /**
+ * Group confirmation state machine
+ *
+ * @return int groupState
+ */
+ public int doGroupConfirmation() {
+ if (confirmState == Constants.CONF_STATE_INPUT) {
+ populateFieldConfirm();
+ return confirmState;
+ }
+
+ if (confirmState == Constants.CONF_STATE_CONFIRMATION){
+ compareConfirmationValues();
+ return confirmState;
+ }
+
+ if (confirmState == Constants.CONF_STATE_IDENTIFICATION){
+ compareIdentificationValues();
+ return confirmState;
+ }
+
+ return Constants.CONF_STATE_UNEXPECTED;
+ }
+
+ private void populateFieldConfirm() {
+
+ StringBuffer result = new StringBuffer();
+ String current = null;
+ BaseModel model = null;
+
+ result.append("<field name = \"" + idConfirm + "\" type = \""
+ + Constants.STR_BOOLEAN + "\">");
+ result.append(Constants.VXML_PROMPT_BEGIN +
+ Constants.STR_CONF_PROMPT_START +
+ Constants.STR_CONF_PROMPT_ENUMERATE + Constants.VXML_PROMPT_END);
+ result.append(Constants.VXML_PROMPT_BEGIN +
+ Constants.STR_CONF_PROMPT_END + Constants.VXML_PROMPT_END);
+
+ Iterator iter = localMap.keySet().iterator();
+ while (iter.hasNext()) {
+ current = (String) iter.next();
+ if (!current.equals(Constants.STR_INIT_ONLY_FLAG)) {
+ model = (BaseModel) localMap.get(current);
+ result.append(Constants.VXML_OPTION_BEGIN);
+ result.append(model.getCanonicalizedValue());
+ result.append(Constants.VXML_OPTION_END);
+ }
+ }
+ result.append("<filled> <submit next =\"" + submit + "\" namelist=\""
+ + idConfirm + "\" /> </filled></field>");
+ try {
+ ctx.getOut().write(result.toString());
+ } catch (IOException ioe) {
+ log.error(ERR_IO_FAILURE);
+ }
+ confirmState = Constants.CONF_STATE_CONFIRMATION;
+ }
+
+ private void compareConfirmationValues() {
+
+ String testConfirm = ctx.getRequest().getParameter(idConfirm);
+ if (testConfirm == null) {
+ confirmState = Constants.CONF_STATE_UNEXPECTED;
+ return;
+ }
+
+ if (confirmState == Constants.CONF_STATE_CONFIRMATION) {
+ if (testConfirm.equals(Constants.STR_TRUE)) {
+ localModel.setConfirmed(Boolean.TRUE);
+ confirmState = Constants.CONF_STATE_DONE;
+ } else if (testConfirm.equals(Constants.STR_FALSE)) {
+ populateFieldIdentification();
+ }
+ }
+
+ }
+
+ private void populateFieldIdentification() {
+ StringBuffer result = new StringBuffer();
+ String current = null;
+ BaseModel model = null;
+
+ result.append("<field name = \"" + idIdentify + "\">" +
+ Constants.VXML_PROMPT_BEGIN + Constants.STR_CONF_PROMPT_SELECT +
+ Constants.VXML_PROMPT_END);
+
+ Iterator iter = localMap.keySet().iterator();
+ while (iter.hasNext()) {
+ current = (String) iter.next();
+ if (!current.equals(Constants.STR_INIT_ONLY_FLAG)) {
+ model = (BaseModel) localMap.get(current);
+ if (model.getConfirmed() == Boolean.FALSE) {
+ result.append(Constants.VXML_OPTION_BEGIN).append(current).
+ append(Constants.VXML_OPTION_END);
+ }
+ }
+ }
+
+ result.append("<filled> <submit next =\"" + submit + "\" namelist=\""
+ + idIdentify + "\" /></filled></field>");
+ try {
+ ctx.getOut().write(result.toString());
+ } catch (IOException ioe) {
+ log.error(ERR_IO_FAILURE);
+ }
+ confirmState = Constants.CONF_STATE_IDENTIFICATION;
+
+ }
+
+ private void compareIdentificationValues() {
+
+ String testIdentify = ctx.getRequest().getParameter(idIdentify);
+ if (testIdentify == null) {
+ confirmState = Constants.CONF_STATE_UNEXPECTED;
+ return;
+ }
+ BaseModel model = null;
+ StringBuffer result = new StringBuffer();
+ Iterator iter = localMap.keySet().iterator();
+ String current = null;
+ while (iter.hasNext()) {
+ current = (String) iter.next();
+ if (current.equals(Constants.STR_INIT_ONLY_FLAG)) {
+ continue;
+ }
+ model = (BaseModel) localMap.get(current);
+ if (confirmState == Constants.CONF_STATE_IDENTIFICATION) {
+ if (testIdentify.equals(current)) {
+ model.setConfirmed(Boolean.FALSE);
+ model.setConfirm(Boolean.TRUE);
+ model.setState(Constants.FSM_INPUT);
+ model.setSkipSubmit(Boolean.FALSE);
+ result.append(Constants.VXML_BLOCK_BEGIN + "OK, lets try " +
+ model.getId() + " again.");
+ result.append("<submit next =\"" + submit + "\" />");
+ result.append(Constants.VXML_BLOCK_END);
+ }
+ }
+ }
+ try {
+ ctx.getOut().write(result.toString());
+ } catch (IOException ioe) {
+ log.error(ERR_IO_FAILURE);
+ }
+ localModel.setState(Constants.GRP_STATE_RUNNING);
+ confirmState = Constants.CONF_STATE_INPUT;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupModel.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupModel.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupModel.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupModel.java Wed Aug 10 14:10:59 2005
@@ -33,95 +33,95 @@
*/
public class GroupModel extends BaseModel
- implements Serializable{
-
- // The map of datamodel of child RDCs; keyed by id
- protected Map localMap;
- // The object that group confirmation is outsourced to
- protected GroupConfirm groupConfirm;
- // The list of currently active children
- // An active child is defined as one that is neither DORMANT nor DONE
- protected List activeChildren;
- // Strategy specific instance data that needs to be cached
- protected transient Object instanceData;
-
- public GroupModel() {
- super();
- this.localMap = new LinkedHashMap();
- this.activeChildren = new ArrayList();
- this.instanceData = null;
- } // GroupModel constructor
+ implements Serializable{
+
+ // The map of datamodel of child RDCs; keyed by id
+ protected Map localMap;
+ // The object that group confirmation is outsourced to
+ protected GroupConfirm groupConfirm;
+ // The list of currently active children
+ // An active child is defined as one that is neither DORMANT nor DONE
+ protected List activeChildren;
+ // Strategy specific instance data that needs to be cached
+ protected transient Object instanceData;
+
+ public GroupModel() {
+ super();
+ this.localMap = new LinkedHashMap();
+ this.activeChildren = new ArrayList();
+ this.instanceData = null;
+ } // GroupModel constructor
-
- /**
- * Get the map of child RDC datamodels
- *
- * @return the map of child RDC datamodels
- */
- public Map getLocalMap() {
- return localMap;
- }
+
+ /**
+ * Get the map of child RDC datamodels
+ *
+ * @return the map of child RDC datamodels
+ */
+ public Map getLocalMap() {
+ return localMap;
+ }
/**
* Set the map of child RDC datamodels
*
* @param localMap - the map of child RDC datamodels
*/
- public void setLocalMap(Map localMap) {
- this.localMap = localMap;
+ public void setLocalMap(Map localMap) {
+ this.localMap = localMap;
}
- /**
- * Get the GroupConfirm object
- *
- * @return groupConfirm the group confirmation object
- */
- public GroupConfirm getGroupConfirm() {
- return groupConfirm;
- }
+ /**
+ * Get the GroupConfirm object
+ *
+ * @return groupConfirm the group confirmation object
+ */
+ public GroupConfirm getGroupConfirm() {
+ return groupConfirm;
+ }
- /**
- * Set the GroupConfirm
- *
- * @param confirm
- */
- public void setGroupConfirm(GroupConfirm groupConfirm) {
- this.groupConfirm = groupConfirm;
- }
+ /**
+ * Set the GroupConfirm
+ *
+ * @param confirm
+ */
+ public void setGroupConfirm(GroupConfirm groupConfirm) {
+ this.groupConfirm = groupConfirm;
+ }
- /**
- * Get the currently active children (not in dormant or done state)
- *
- * @return activeChildren
- */
- public List getActiveChildren() {
- return activeChildren;
- }
+ /**
+ * Get the currently active children (not in dormant or done state)
+ *
+ * @return activeChildren
+ */
+ public List getActiveChildren() {
+ return activeChildren;
+ }
- /**
- * Set the currently active children
- *
- * @param list
- */
- public void setActiveChildren(List list) {
- activeChildren = list;
- }
-
- /**
- * Get the instance data
- *
- * @return Returns the instanceData.
- */
- public Object getInstanceData() {
- return instanceData;
- }
-
- /**
- * Set the instance data
- *
- * @param instanceData The instanceData to set.
- */
- public void setInstanceData(Object instanceData) {
- this.instanceData = instanceData;
- }
+ /**
+ * Set the currently active children
+ *
+ * @param list
+ */
+ public void setActiveChildren(List list) {
+ activeChildren = list;
+ }
+
+ /**
+ * Get the instance data
+ *
+ * @return Returns the instanceData.
+ */
+ public Object getInstanceData() {
+ return instanceData;
+ }
+
+ /**
+ * Set the instance data
+ *
+ * @param instanceData The instanceData to set.
+ */
+ public void setInstanceData(Object instanceData) {
+ this.instanceData = instanceData;
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupTag.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupTag.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupTag.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/GroupTag.java Wed Aug 10 14:10:59 2005
@@ -37,175 +37,175 @@
* @author Rahul Akolkar
*/
public class GroupTag extends SimpleTagSupport {
-
- // Error messages (to be i18n'zed)
- private static final String ERR_NO_SUCH_STRATEGY = "<!-- GroupTag: No " +
- "strategy class found - \"{0}\" -->\n";
-
- // Logging
- private static Log log = LogFactory.getLog(GroupTag.class);
-
- // CLASS PROPERTIES
- // The unique identifier associated with the group
- private String id;
- // Holds the submit url
- private String submit;
- // Holds the configuration details for the dialog management strategy
- // The interpretation of this attribute is upto the DM strategy plugged in
- private String config;
- // Indicates whether group level confirmation is requested
- // Overrides atom level confirmation, if specified
- private Boolean confirm;
- // The class name that implements the dialog management strategy
- private String strategy;
-
- /* Constructor */
- public GroupTag() {
- super();
- id = null;
- submit = null;
- config = null;
- strategy = null;
- confirm = Boolean.FALSE;
- }
-
- /**
- * Gets the ID of the group
- *
- * @return ID The group's strategy
- */
- public String getId() {
- return id;
- }
-
- /**
- * Sets the id of the group
- *
- * @param id The group's id
- */
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- * Gets the submit URL where group should submit
- *
- * @return submit The group's submit URL
- */
- public String getSubmit() {
- return submit;
- }
-
- /**
- * Sets the submit URL for the group
- *
- * @param submit The group's submit URL
- */
- public void setSubmit(String submit) {
- this.submit = submit;
- }
-
- /**
- * Gets the configuration URI of the group
- *
- * @return config The group's configuration URI
- */
- public String getConfig() {
- return config;
- }
-
- /**
- * Sets the configuration URI of the group
- *
- * @param config The group's configuration URI
- */
- public void setConfig(String config) {
- this.config = config;
- }
-
- /**
- * Get the group level confirmation
- *
- * @return confirm
- */
- public Boolean getConfirm() {
- return confirm;
- }
-
- /**
- * Set the group level confirmation
- *
- * @param Boolean confirm
- */
- public void setConfirm(Boolean confirm) {
- this.confirm = confirm;
- }
-
- /**
- * Get the class name that implements the DM strategy
- *
- * @return strategy the class name
- */
- public String getStrategy() {
- return strategy;
- }
-
- /**
- * Set the class name that implements the DM strategy
- *
- * @param strategy the class name
- */
- public void setStrategy(String strategy) {
- this.strategy = strategy;
- }
-
- /**
- * Make JspContext visible to the DM strategy
- *
- * @return JspContext
- */
- public JspContext getJspContext() {
- return super.getJspContext();
- }
-
- /**
- * Has the state machine for the group
- *
- * Uses a pluggable dialog management strategy
- */
- public void doTag() throws JspException, IOException {
-
- DialogManager dm = null;
- try {
- dm = (DialogManager) Class.forName(strategy).newInstance();
- } catch (Exception e) {
- MessageFormat msgFormat = new MessageFormat(ERR_NO_SUCH_STRATEGY);
- String errMsg = msgFormat.format(new Object[] {strategy});
- // Log error and send comment to client
- log.error(errMsg);
- ((PageContext) getJspContext()).getOut().write(errMsg);
- return;
- }
-
- if (submit == null || submit.length() == 0) {
- // to-do - investigate why servlet path won't work in VTK,
- // and if session id needs to be appended
- submit = ((HttpServletRequest) ((PageContext) getJspContext()).
- getRequest()).getRequestURI();
- }
-
- dm.setGroupTag(this);
-
- if (!dm.initialize(getJspContext(), getJspBody())) {
- return;
- }
-
- dm.collect(getJspContext(), getJspBody());
-
- dm.confirm();
-
- dm.finish(getJspContext());
-
- }
+
+ // Error messages (to be i18n'zed)
+ private static final String ERR_NO_SUCH_STRATEGY = "<!-- GroupTag: No " +
+ "strategy class found - \"{0}\" -->\n";
+
+ // Logging
+ private static Log log = LogFactory.getLog(GroupTag.class);
+
+ // CLASS PROPERTIES
+ // The unique identifier associated with the group
+ private String id;
+ // Holds the submit url
+ private String submit;
+ // Holds the configuration details for the dialog management strategy
+ // The interpretation of this attribute is upto the DM strategy plugged in
+ private String config;
+ // Indicates whether group level confirmation is requested
+ // Overrides atom level confirmation, if specified
+ private Boolean confirm;
+ // The class name that implements the dialog management strategy
+ private String strategy;
+
+ /* Constructor */
+ public GroupTag() {
+ super();
+ id = null;
+ submit = null;
+ config = null;
+ strategy = null;
+ confirm = Boolean.FALSE;
+ }
+
+ /**
+ * Gets the ID of the group
+ *
+ * @return ID The group's strategy
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Sets the id of the group
+ *
+ * @param id The group's id
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Gets the submit URL where group should submit
+ *
+ * @return submit The group's submit URL
+ */
+ public String getSubmit() {
+ return submit;
+ }
+
+ /**
+ * Sets the submit URL for the group
+ *
+ * @param submit The group's submit URL
+ */
+ public void setSubmit(String submit) {
+ this.submit = submit;
+ }
+
+ /**
+ * Gets the configuration URI of the group
+ *
+ * @return config The group's configuration URI
+ */
+ public String getConfig() {
+ return config;
+ }
+
+ /**
+ * Sets the configuration URI of the group
+ *
+ * @param config The group's configuration URI
+ */
+ public void setConfig(String config) {
+ this.config = config;
+ }
+
+ /**
+ * Get the group level confirmation
+ *
+ * @return confirm
+ */
+ public Boolean getConfirm() {
+ return confirm;
+ }
+
+ /**
+ * Set the group level confirmation
+ *
+ * @param Boolean confirm
+ */
+ public void setConfirm(Boolean confirm) {
+ this.confirm = confirm;
+ }
+
+ /**
+ * Get the class name that implements the DM strategy
+ *
+ * @return strategy the class name
+ */
+ public String getStrategy() {
+ return strategy;
+ }
+
+ /**
+ * Set the class name that implements the DM strategy
+ *
+ * @param strategy the class name
+ */
+ public void setStrategy(String strategy) {
+ this.strategy = strategy;
+ }
+
+ /**
+ * Make JspContext visible to the DM strategy
+ *
+ * @return JspContext
+ */
+ public JspContext getJspContext() {
+ return super.getJspContext();
+ }
+
+ /**
+ * Has the state machine for the group
+ *
+ * Uses a pluggable dialog management strategy
+ */
+ public void doTag() throws JspException, IOException {
+
+ DialogManager dm = null;
+ try {
+ dm = (DialogManager) Class.forName(strategy).newInstance();
+ } catch (Exception e) {
+ MessageFormat msgFormat = new MessageFormat(ERR_NO_SUCH_STRATEGY);
+ String errMsg = msgFormat.format(new Object[] {strategy});
+ // Log error and send comment to client
+ log.error(errMsg);
+ ((PageContext) getJspContext()).getOut().write(errMsg);
+ return;
+ }
+
+ if (submit == null || submit.length() == 0) {
+ // to-do - investigate why servlet path won't work in VTK,
+ // and if session id needs to be appended
+ submit = ((HttpServletRequest) ((PageContext) getJspContext()).
+ getRequest()).getRequestURI();
+ }
+
+ dm.setGroupTag(this);
+
+ if (!dm.initialize(getJspContext(), getJspBody())) {
+ return;
+ }
+
+ dm.collect(getJspContext(), getJspBody());
+
+ dm.confirm();
+
+ dm.finish(getJspContext());
+
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/IncludeFSMFragmentTag.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/IncludeFSMFragmentTag.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/IncludeFSMFragmentTag.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/IncludeFSMFragmentTag.java Wed Aug 10 14:10:59 2005
@@ -38,64 +38,64 @@
*/
public class IncludeFSMFragmentTag
extends SimpleTagSupport {
-
- // Error messages (to be i18n'zed)
- private static final String ERR_INCLUDE = "<!-- Error after " +
- "rdc:include to: \"{0}\" with message: \"{1}\" -->\n";
-
- // Logging
- private static Log log = LogFactory.getLog(IncludeFSMFragmentTag.class);
+
+ // Error messages (to be i18n'zed)
+ private static final String ERR_INCLUDE = "<!-- Error after " +
+ "rdc:include to: \"{0}\" with message: \"{1}\" -->\n";
+
+ // Logging
+ private static Log log = LogFactory.getLog(IncludeFSMFragmentTag.class);
// The RDC simple template bean
RDCTemplate template;
// Page context for the RDC data collection
PageContext context;
- /*
- * Constructor
- */
+ /*
+ * Constructor
+ */
public IncludeFSMFragmentTag() {
- super();
- template = null;
- context = null;
+ super();
+ template = null;
+ context = null;
+ }
+
+ /**
+ * Set the RDCTemplate
+ *
+ * @param template
+ */
+ public void setTemplate(RDCTemplate template) {
+ this.template = template;
+ }
+
+ /**
+ * Set the PageContext
+ *
+ * @param PageContext context
+ */
+ public void setContext(PageContext context) {
+ this.context = context;
}
-
- /**
- * Set the RDCTemplate
- *
- * @param template
- */
- public void setTemplate(RDCTemplate template) {
- this.template = template;
- }
-
- /**
- * Set the PageContext
- *
- * @param PageContext context
- */
- public void setContext(PageContext context) {
- this.context = context;
- }
- /**
- * Collect data from the RDC layer and post it into the viewsMap
- * according to the RDC-struts interface contract
- *
- */
+ /**
+ * Collect data from the RDC layer and post it into the viewsMap
+ * according to the RDC-struts interface contract
+ *
+ */
public void doTag()
throws IOException, JspException, JspTagException {
JspWriter out = context.getOut();
- try {
- context.getRequest().setAttribute("model",template);
- context.getRequest().setAttribute("constants",new Constants());
- context.include(template.getFsmFragment());
+ try {
+ context.getRequest().setAttribute("model",template);
+ context.getRequest().setAttribute("constants",new Constants());
+ context.include(template.getFsmFragment());
} catch (Exception e) {
- MessageFormat msgFormat = new MessageFormat(ERR_INCLUDE);
- String errMsg = msgFormat.format(new Object[] {template.
- getFsmFragment(), e.getMessage()});
- log.error(errMsg);
+ MessageFormat msgFormat = new MessageFormat(ERR_INCLUDE);
+ String errMsg = msgFormat.format(new Object[] {template.
+ getFsmFragment(), e.getMessage()});
+ log.error(errMsg);
out.write(errMsg);
} // end of try-catch
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/NBestResults.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/NBestResults.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/NBestResults.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/NBestResults.java Wed Aug 10 14:10:59 2005
@@ -39,21 +39,21 @@
// for each of the n-best results
List confidences, interpretations, utterances;
- /* Constructor */
+ /* Constructor */
public NBestResults() {
confidences = new ArrayList();
interpretations = new ArrayList();
utterances = new ArrayList();
}
- /**
- * Get the number of results stored
- *
- * @return int the number of results stored
- */
+ /**
+ * Get the number of results stored
+ *
+ * @return int the number of results stored
+ */
public int getNumNBest()
{
- // At any point, all arraylists have same size
+ // At any point, all arraylists have same size
return confidences.size();
}
@@ -63,84 +63,84 @@
* @param n the index of the result
* @return the float value of the confidence
*/
- public float getNthConfidence(int n) {
- if (n < confidences.size()) {
- return ((Float)confidences.get(n)).floatValue();
- }
- return 0.0F;
- }
+ public float getNthConfidence(int n) {
+ if (n < confidences.size()) {
+ return ((Float)confidences.get(n)).floatValue();
+ }
+ return 0.0F;
+ }
- /**
- * Get interpretation for Nth result, which is stored as a HashMap
- * of attribute-value pairs
- *
- * @param n the index of the result
- * @return the interpretation
- */
- public Map getNthInterpretation(int n) {
- if (n < interpretations.size()) {
- return (Map) interpretations.get(n);
- }
- return null;
- }
+ /**
+ * Get interpretation for Nth result, which is stored as a HashMap
+ * of attribute-value pairs
+ *
+ * @param n the index of the result
+ * @return the interpretation
+ */
+ public Map getNthInterpretation(int n) {
+ if (n < interpretations.size()) {
+ return (Map) interpretations.get(n);
+ }
+ return null;
+ }
- /**
- * Get utterance for Nth result
- *
- * @param n the index of the result
- * @return the utterance
- */
- public String getNthUtterance(int n) {
- if (n < utterances.size()) {
- return (String)utterances.get(n);
- }
- return null;
- }
-
- /**
- * Populate this object with the n-best results corresponding
- * to this serialized string
- *
- * @param serializedNBest the serialized n-best result string
- * obtained from the vxml browser
- * To understand this method, look at the nbest.js file in the
- * .grammar directory
- */
+ /**
+ * Get utterance for Nth result
+ *
+ * @param n the index of the result
+ * @return the utterance
+ */
+ public String getNthUtterance(int n) {
+ if (n < utterances.size()) {
+ return (String)utterances.get(n);
+ }
+ return null;
+ }
+
+ /**
+ * Populate this object with the n-best results corresponding
+ * to this serialized string
+ *
+ * @param serializedNBest the serialized n-best result string
+ * obtained from the vxml browser
+ * To understand this method, look at the nbest.js file in the
+ * .grammar directory
+ */
public void setNBestResults(String serializedNBest) {
-
- String decodedNBest = null;
- try {
- decodedNBest = URLDecoder.decode(serializedNBest, "UTF-8");
- } catch (UnsupportedEncodingException uee){
- String errMsg = "Deserialization of n-best tokenizer failed: " +
- "Cannot decode using UTF-8 encoding scheme";
- throw new IllegalArgumentException(errMsg);
- }
- if (decodedNBest == null) {
- String errMsg = "Deserialization of n-best tokenizer failed: " +
- "Cannot decode given encoded string: " + serializedNBest;
- throw new IllegalArgumentException(errMsg);
- }
+
+ String decodedNBest = null;
+ try {
+ decodedNBest = URLDecoder.decode(serializedNBest, "UTF-8");
+ } catch (UnsupportedEncodingException uee){
+ String errMsg = "Deserialization of n-best tokenizer failed: " +
+ "Cannot decode using UTF-8 encoding scheme";
+ throw new IllegalArgumentException(errMsg);
+ }
+ if (decodedNBest == null) {
+ String errMsg = "Deserialization of n-best tokenizer failed: " +
+ "Cannot decode given encoded string: " + serializedNBest;
+ throw new IllegalArgumentException(errMsg);
+ }
StringTokenizer nBestTok = new StringTokenizer(decodedNBest, ";");
if (nBestTok.countTokens() % 3 != 0) {
- String errMsg = "Deserialization of n-best tokenizer failed: " +
- "Illegal Argument \"" + serializedNBest + "\", number " +
- "of tokens: " + nBestTok.countTokens();
- throw new IllegalArgumentException(errMsg);
+ String errMsg = "Deserialization of n-best tokenizer failed: " +
+ "Illegal Argument \"" + serializedNBest + "\", number " +
+ "of tokens: " + nBestTok.countTokens();
+ throw new IllegalArgumentException(errMsg);
}
- while (nBestTok.hasMoreTokens()) {
+ while (nBestTok.hasMoreTokens()) {
confidences.add(new Float(nBestTok.nextToken()));
utterances.add(nBestTok.nextToken());
StringTokenizer interpTok =
- new StringTokenizer(nBestTok.nextToken(), ",");
+ new StringTokenizer(nBestTok.nextToken(), ",");
Map interpMap = new HashMap();
while (interpTok.hasMoreTokens()) {
StringTokenizer avst =
- new StringTokenizer(interpTok.nextToken(), "=");
+ new StringTokenizer(interpTok.nextToken(), "=");
if (avst.countTokens() > 1) {
- interpMap.put(avst.nextToken(),avst.nextToken());
+ interpMap.put(avst.nextToken(),avst.nextToken());
} else {
- interpMap.put("",avst.nextToken());
+ interpMap.put("",avst.nextToken());
}
}
interpretations.add(interpMap);
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/RDCTemplate.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/RDCTemplate.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/RDCTemplate.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/RDCTemplate.java Wed Aug 10 14:10:59 2005
@@ -36,246 +36,246 @@
* @author Rahul Akolkar
*/
public class RDCTemplate extends BaseModel {
-
- // Error messages (to be i18n'zed)
- private static final String ERR_BAD_PROP = "Did not populate " +
- " following property(ies) for RDC template instance with id \"{0}\"" +
- " : \"{1}\" as properties defined in BaseModel should not be " +
- "populated via the grammars/constraints/dynamic attributes. " +
- "Rename these.";
- private static final String ERR_BEAN_POPULATE = "Failure while " +
- "populationg RDC template instance with id \"{0}\", with message " +
- "\"{1}\"";
-
- // Logging
- private static Log log = LogFactory.getLog(RDCTemplate.class);
-
- /** The instance specific data that is passed in */
- protected Object data;
- /** The fully qualified class name of the model bean for this
- * instance of the RDC template */
- protected String bean;
- /** The fragment that will override any or all of the
- * default fsm as needed for this instance of the template */
- protected String fsmFragment;
- /** The instance specific constraints on the value to be collected. */
- protected Map constraints;
- /** The instance specific dynamic tag attributes. */
- protected Map dynamicAttributes;
- /** The property that governs whether we will attempt to populate this
- * template instance with the grammars that will be passed in */
- protected boolean populateGrammars;
-
- /**
- * Sets default values for all data members
- */
- public RDCTemplate() {
- super();
- this.data = null;
- this.bean = RDCTemplate.class.getName();
- this.fsmFragment = null;
- this.constraints = null;
- this.dynamicAttributes = null;
- this.populateGrammars = false;
- }
-
- /**
- * Get the data value that was passed in
- *
- * @return data
- */
- public Object getData() {
- return this.data;
- }
-
- /**
- * Sets the data value
- *
- * @param data
- */
- public void setData(Object data) {
- if (data != null) {
- this.data = data;
- }
- }
-
- /**
- * Get the data value that was passed in
- *
- * @return string bean
- */
- public String getBean() {
- return bean;
- }
-
- /**
- * Sets the bean value
- *
- * @param string bean
- */
- public void setBean(String bean) {
- if (bean != null) {
- this.bean = bean;
- }
- }
-
- /**
- * Get the tag fragment URI overriding the default FSM
- * defined in <fsm-run>
- *
- * @return fsmTagFragment
- */
- public String getFsmFragment() {
- return this.fsmFragment;
- }
-
- /**
- * Set the tag fragment URI overriding the default FSM
- * defined in <fsm-run>
- *
- * @param fsmTagFragment
- */
- public void setFsmFragment(String fsmFragment) {
- if (fsmFragment != null) {
- this.fsmFragment = fsmFragment;
- }
- }
-
- /**
- * Get the constraints on the value to be collected. Only
- * those constraints passed in via the constraints attribute
- * of this instance of the template tag will be returned.
- *
- * @return constraints
- */
- public Map getConstraints() {
- return this.constraints;
- }
-
- /**
- * Set the constraints on the value to be collected
- *
- * @param constraints
- */
- public void setConstraints(Map constraints) {
- if (constraints != null) {
- this.constraints = constraints;
- if (this.constraints.size() > 0) {
- populate(this.constraints);
- }
- }
- }
-
- /**
- * Set the dynamic attributes data received from this tag instance
- *
- * @param attrsMap The dynamic attributes name value map
- */
- public void setDynamicAttributes(Map dynamicAttributes) {
- if (dynamicAttributes != null) {
- this.dynamicAttributes = dynamicAttributes;
- if (this.dynamicAttributes.size() > 0) {
- populate(this.dynamicAttributes);
- }
- }
- }
-
- /**
- * Sets the grammar(s). The param can be an array of some combination
- * of Grammar objects and string URIs or a Grammar object or a string URI.
- *
- * @param grammar
- */
- public void setGrammar(Object grammar) {
- Map grammarMap = new HashMap();
- if (grammar != null) {
- if (grammar instanceof Object[]) {
- Object[] grammarsArray = (Object []) grammar;
- for (int i=0; i < grammarsArray.length; i++) {
- Object grammarObj = grammarsArray[i];
- if (grammarObj instanceof Grammar) {
- addGrammar((Grammar)grammarObj, grammarMap);
- } else if (grammarObj instanceof String) {
- // Assume voice and external (not inline)
- addGrammar(new Grammar((String)grammarObj,
- Boolean.FALSE, Boolean.FALSE, null), null);
- }
- }
- } else if (grammar instanceof Grammar) {
- addGrammar((Grammar)grammar, grammarMap);
- } else if (grammar instanceof String) {
- // Assume voice and external (not inline)
- addGrammar(new Grammar((String)grammar, Boolean.FALSE,
- Boolean.FALSE, null), null);
- }
- }
- if (populateGrammars && grammarMap.size() > 0) {
- populate(grammarMap);
- }
- initComponentGrammars();
- }
-
- /**
- * Hook for instances to prepare grammars for first round trip
- */
- public void initComponentGrammars() {
- // hook for subclasses
- }
-
- /**
- * Add grammar object
- */
- private void addGrammar(Grammar grammar, Map grammarMap) {
- this.grammars.add(grammar);
- if (populateGrammars && grammarMap != null) {
- String name = grammar.getName();
- // We cannot populate anonymous grammars
- if (!RDCUtils.isStringEmpty(name)) {
- grammarMap.put(name, grammar);
- }
- }
- }
-
- /**
- * Populate this bean with supplied property value pairs
- */
- private void populate(Map props2values) {
- Map safeProps = new HashMap(props2values);
- Set badProps = props2values.keySet();
- badProps.retainAll(illegalProperties);
- if (badProps.size() > 0) {
- // tsk tsk ... how could you do that
- Object[] badPropsArr = badProps.toArray();
- String badPropsStr = "";
- for (int i = 0; i < badPropsArr.length; i++) {
- String badProp = (String)badPropsArr[i];
- safeProps.remove(badProp);
- badPropsStr += "\"" + badProp + "\", ";
- }
- MessageFormat msgFormat = new MessageFormat(ERR_BAD_PROP);
- log.warn(msgFormat.format(new Object[] {getId(), badPropsStr}));
- }
- try {
- BeanUtils.populate(this, safeProps);
- } catch (Exception e) {
- MessageFormat msgFormat = new MessageFormat(ERR_BEAN_POPULATE);
- log.warn(msgFormat.format(new Object[] {getId(), e.getMessage()}));
- }
- }
-
- /** Ensure that the grammars and constraints population mechanism is
- * not misused */
- private static final Set illegalProperties = new HashSet();
- /*
- * Strictly illegal properties are those defined in BaseModel. Beyond
- * that, we are willing to trust the user ;-)
- */
- static {
- Field[] fields = BaseModel.class.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- String fieldName = fields[i].getName();
- illegalProperties.add(fieldName);
- }
- }
+
+ // Error messages (to be i18n'zed)
+ private static final String ERR_BAD_PROP = "Did not populate " +
+ " following property(ies) for RDC template instance with id \"{0}\"" +
+ " : \"{1}\" as properties defined in BaseModel should not be " +
+ "populated via the grammars/constraints/dynamic attributes. " +
+ "Rename these.";
+ private static final String ERR_BEAN_POPULATE = "Failure while " +
+ "populationg RDC template instance with id \"{0}\", with message " +
+ "\"{1}\"";
+
+ // Logging
+ private static Log log = LogFactory.getLog(RDCTemplate.class);
+
+ /** The instance specific data that is passed in */
+ protected Object data;
+ /** The fully qualified class name of the model bean for this
+ * instance of the RDC template */
+ protected String bean;
+ /** The fragment that will override any or all of the
+ * default fsm as needed for this instance of the template */
+ protected String fsmFragment;
+ /** The instance specific constraints on the value to be collected. */
+ protected Map constraints;
+ /** The instance specific dynamic tag attributes. */
+ protected Map dynamicAttributes;
+ /** The property that governs whether we will attempt to populate this
+ * template instance with the grammars that will be passed in */
+ protected boolean populateGrammars;
+
+ /**
+ * Sets default values for all data members
+ */
+ public RDCTemplate() {
+ super();
+ this.data = null;
+ this.bean = RDCTemplate.class.getName();
+ this.fsmFragment = null;
+ this.constraints = null;
+ this.dynamicAttributes = null;
+ this.populateGrammars = false;
+ }
+
+ /**
+ * Get the data value that was passed in
+ *
+ * @return data
+ */
+ public Object getData() {
+ return this.data;
+ }
+
+ /**
+ * Sets the data value
+ *
+ * @param data
+ */
+ public void setData(Object data) {
+ if (data != null) {
+ this.data = data;
+ }
+ }
+
+ /**
+ * Get the data value that was passed in
+ *
+ * @return string bean
+ */
+ public String getBean() {
+ return bean;
+ }
+
+ /**
+ * Sets the bean value
+ *
+ * @param string bean
+ */
+ public void setBean(String bean) {
+ if (bean != null) {
+ this.bean = bean;
+ }
+ }
+
+ /**
+ * Get the tag fragment URI overriding the default FSM
+ * defined in <fsm-run>
+ *
+ * @return fsmTagFragment
+ */
+ public String getFsmFragment() {
+ return this.fsmFragment;
+ }
+
+ /**
+ * Set the tag fragment URI overriding the default FSM
+ * defined in <fsm-run>
+ *
+ * @param fsmTagFragment
+ */
+ public void setFsmFragment(String fsmFragment) {
+ if (fsmFragment != null) {
+ this.fsmFragment = fsmFragment;
+ }
+ }
+
+ /**
+ * Get the constraints on the value to be collected. Only
+ * those constraints passed in via the constraints attribute
+ * of this instance of the template tag will be returned.
+ *
+ * @return constraints
+ */
+ public Map getConstraints() {
+ return this.constraints;
+ }
+
+ /**
+ * Set the constraints on the value to be collected
+ *
+ * @param constraints
+ */
+ public void setConstraints(Map constraints) {
+ if (constraints != null) {
+ this.constraints = constraints;
+ if (this.constraints.size() > 0) {
+ populate(this.constraints);
+ }
+ }
+ }
+
+ /**
+ * Set the dynamic attributes data received from this tag instance
+ *
+ * @param attrsMap The dynamic attributes name value map
+ */
+ public void setDynamicAttributes(Map dynamicAttributes) {
+ if (dynamicAttributes != null) {
+ this.dynamicAttributes = dynamicAttributes;
+ if (this.dynamicAttributes.size() > 0) {
+ populate(this.dynamicAttributes);
+ }
+ }
+ }
+
+ /**
+ * Sets the grammar(s). The param can be an array of some combination
+ * of Grammar objects and string URIs or a Grammar object or a string URI.
+ *
+ * @param grammar
+ */
+ public void setGrammar(Object grammar) {
+ Map grammarMap = new HashMap();
+ if (grammar != null) {
+ if (grammar instanceof Object[]) {
+ Object[] grammarsArray = (Object []) grammar;
+ for (int i=0; i < grammarsArray.length; i++) {
+ Object grammarObj = grammarsArray[i];
+ if (grammarObj instanceof Grammar) {
+ addGrammar((Grammar)grammarObj, grammarMap);
+ } else if (grammarObj instanceof String) {
+ // Assume voice and external (not inline)
+ addGrammar(new Grammar((String)grammarObj,
+ Boolean.FALSE, Boolean.FALSE, null), null);
+ }
+ }
+ } else if (grammar instanceof Grammar) {
+ addGrammar((Grammar)grammar, grammarMap);
+ } else if (grammar instanceof String) {
+ // Assume voice and external (not inline)
+ addGrammar(new Grammar((String)grammar, Boolean.FALSE,
+ Boolean.FALSE, null), null);
+ }
+ }
+ if (populateGrammars && grammarMap.size() > 0) {
+ populate(grammarMap);
+ }
+ initComponentGrammars();
+ }
+
+ /**
+ * Hook for instances to prepare grammars for first round trip
+ */
+ public void initComponentGrammars() {
+ // hook for subclasses
+ }
+
+ /**
+ * Add grammar object
+ */
+ private void addGrammar(Grammar grammar, Map grammarMap) {
+ this.grammars.add(grammar);
+ if (populateGrammars && grammarMap != null) {
+ String name = grammar.getName();
+ // We cannot populate anonymous grammars
+ if (!RDCUtils.isStringEmpty(name)) {
+ grammarMap.put(name, grammar);
+ }
+ }
+ }
+
+ /**
+ * Populate this bean with supplied property value pairs
+ */
+ private void populate(Map props2values) {
+ Map safeProps = new HashMap(props2values);
+ Set badProps = props2values.keySet();
+ badProps.retainAll(illegalProperties);
+ if (badProps.size() > 0) {
+ // tsk tsk ... how could you do that
+ Object[] badPropsArr = badProps.toArray();
+ String badPropsStr = "";
+ for (int i = 0; i < badPropsArr.length; i++) {
+ String badProp = (String)badPropsArr[i];
+ safeProps.remove(badProp);
+ badPropsStr += "\"" + badProp + "\", ";
+ }
+ MessageFormat msgFormat = new MessageFormat(ERR_BAD_PROP);
+ log.warn(msgFormat.format(new Object[] {getId(), badPropsStr}));
+ }
+ try {
+ BeanUtils.populate(this, safeProps);
+ } catch (Exception e) {
+ MessageFormat msgFormat = new MessageFormat(ERR_BEAN_POPULATE);
+ log.warn(msgFormat.format(new Object[] {getId(), e.getMessage()}));
+ }
+ }
+
+ /** Ensure that the grammars and constraints population mechanism is
+ * not misused */
+ private static final Set illegalProperties = new HashSet();
+ /*
+ * Strictly illegal properties are those defined in BaseModel. Beyond
+ * that, we are willing to trust the user ;-)
+ */
+ static {
+ Field[] fields = BaseModel.class.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++) {
+ String fieldName = fields[i].getName();
+ illegalProperties.add(fieldName);
+ }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPeek.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPeek.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPeek.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPeek.java Wed Aug 10 14:10:59 2005
@@ -23,53 +23,50 @@
import javax.servlet.jsp.tagext.SimpleTagSupport;
/**
- * <p>Peek into the top of a stack and make it available as
- * a page scoped object.</p>
- *
+ * <p>
+ * Peek into the top of a stack and make it available as a page scoped object.
+ * </p>
+ *
* @author Abhishek Verma
* @author Rahul Akolkar
*/
-public class StackPeek
- extends SimpleTagSupport
-{
- // Name of the exported page scoped variable for the top of stack.
- private String var;
- // A stack of rdc datamodels
- private Stack stack;
-
- /**
- * Set the name of exported page scoped variable
- *
- * @param var - name of exported page scoped variable
- */
- public void setVar( String var )
- {
- this.var = var;
- }
-
- /**
- * Set the stack of rdc datamodels
- *
- * @param stack - the stack of rdc datamodels
- */
- public void setStack( Stack stack )
- {
- this.stack = stack;
- }
-
- public StackPeek()
- {
- super();
- } // StackPeek constructor
-
- public void doTag() throws JspException, java.io.IOException
- {
- if ( stack == null )
- {
- getJspContext().setAttribute( var, null );
- } else {
- getJspContext().setAttribute( var, stack.peek() );
- } // end of else
- }
+public class StackPeek extends SimpleTagSupport {
+ // Name of the exported page scoped variable for the top of stack.
+ private String var;
+
+ // A stack of rdc datamodels
+ private Stack stack;
+
+ /**
+ * Set the name of exported page scoped variable
+ *
+ * @param var -
+ * name of exported page scoped variable
+ */
+ public void setVar(String var) {
+ this.var = var;
+ }
+
+ /**
+ * Set the stack of rdc datamodels
+ *
+ * @param stack -
+ * the stack of rdc datamodels
+ */
+ public void setStack(Stack stack) {
+ this.stack = stack;
+ }
+
+ public StackPeek() {
+ super();
+ } // StackPeek constructor
+
+ public void doTag() throws JspException, java.io.IOException {
+ if (stack == null) {
+ getJspContext().setAttribute(var, null);
+ } else {
+ getJspContext().setAttribute(var, stack.peek());
+ } // end of else
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPop.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPop.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPop.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPop.java Wed Aug 10 14:10:59 2005
@@ -23,53 +23,50 @@
import javax.servlet.jsp.tagext.SimpleTagSupport;
/**
- * <p>Pop the top of a stack and make it available as
- * a page scoped object.</p>
- *
+ * <p>
+ * Pop the top of a stack and make it available as a page scoped object.
+ * </p>
+ *
* @author Abhishek Verma
* @author Rahul Akolkar
*/
-public class StackPop
- extends SimpleTagSupport
-{
- // Name of the exported page scoped variable for the top of stack.
+public class StackPop extends SimpleTagSupport {
+ // Name of the exported page scoped variable for the top of stack.
private String var;
+
// A stack of rdc datamodels
private Stack stack;
/**
* Set the name of exported page scoped variable
*
- * @param var - name of exported page scoped variable
+ * @param var -
+ * name of exported page scoped variable
*/
- public void setVar( String var )
- {
+ public void setVar(String var) {
this.var = var;
}
/**
* Set the stack of rdc datamodels
*
- * @param stack - the stack of rdc datamodels
+ * @param stack -
+ * the stack of rdc datamodels
*/
- public void setStack( Stack stack )
- {
+ public void setStack(Stack stack) {
this.stack = stack;
}
- public StackPop()
- {
+ public StackPop() {
super();
} // StackPop constructor
- public void doTag() throws JspException, java.io.IOException
- {
- if ( stack == null )
- {
- getJspContext().setAttribute( var, null );
- } else {
- getJspContext().setAttribute( var, stack.pop() );
+ public void doTag() throws JspException, java.io.IOException {
+ if (stack == null) {
+ getJspContext().setAttribute(var, null);
+ } else {
+ getJspContext().setAttribute(var, stack.pop());
} // end of else
}
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPush.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPush.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPush.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StackPush.java Wed Aug 10 14:10:59 2005
@@ -24,49 +24,45 @@
/**
* Push an object on to the stack.
- *
+ *
* @author Abhishek Verma
* @author Rahul Akolkar
*/
-public class StackPush
- extends SimpleTagSupport
-{
- // A stack of rdc datamodels
- private Stack stack;
- // The object to be pushed on to the stack. It is an rdc datamodel
- private Object element;
-
- /**
- * Set the stack of rdc datamodels
- *
- * @param stack - the stack of rdc datamodels
- */
- public void setStack( Stack stack )
- {
- this.stack = stack;
- }
-
- /**
- * Sets the object to be pushed on to the stack
- *
- * @param element - rdc datamodel to be pushed on to the stack
- */
- public void setElement( Object element )
- {
- this.element = element;
- }
-
- public StackPush()
- {
- super();
- } // StackPush constructor
-
- public void doTag() throws JspException, java.io.IOException
- {
- if ( stack != null )
- {
- stack.push( element );
- }
- }
+public class StackPush extends SimpleTagSupport {
+ // A stack of rdc datamodels
+ private Stack stack;
+
+ // The object to be pushed on to the stack. It is an rdc datamodel
+ private Object element;
+
+ /**
+ * Set the stack of rdc datamodels
+ *
+ * @param stack -
+ * the stack of rdc datamodels
+ */
+ public void setStack(Stack stack) {
+ this.stack = stack;
+ }
+
+ /**
+ * Sets the object to be pushed on to the stack
+ *
+ * @param element -
+ * rdc datamodel to be pushed on to the stack
+ */
+ public void setElement(Object element) {
+ this.element = element;
+ }
+
+ public StackPush() {
+ super();
+ } // StackPush constructor
+
+ public void doTag() throws JspException, java.io.IOException {
+ if (stack != null) {
+ stack.push(element);
+ }
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsErrorsTag.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsErrorsTag.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsErrorsTag.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsErrorsTag.java Wed Aug 10 14:10:59 2005
@@ -42,65 +42,65 @@
public class StrutsErrorsTag
extends SimpleTagSupport {
- /*
- * Constructor
- */
+ /*
+ * Constructor
+ */
public StrutsErrorsTag() {
- super();
+ super();
}
- /**
- * Play out any errors messages from the preceding struts action.
- * This basic implementation reports all errors at once and disregards
- * any values specified via the message.
- *
- */
+ /**
+ * Play out any errors messages from the preceding struts action.
+ * This basic implementation reports all errors at once and disregards
+ * any values specified via the message.
+ *
+ */
public void doTag()
throws IOException, JspException, JspTagException {
JspWriter out = getJspContext().getOut();
Object errors = getJspContext().findAttribute(Globals.ERROR_KEY);
- if (errors == null) {
- return;
- } else if (errors instanceof ActionErrors) {
- // deprecated in Struts 1.2
- out.print("<block>");
- ActionErrors actionErrors = (ActionErrors) errors;
- if (!actionErrors.isEmpty()) {
- Iterator iter = actionErrors.get();
- while (iter.hasNext()) {
- ActionMessage msg = (ActionMessage)iter.next();
- if (msg != null) {
- out.print("<prompt>" + msg.getKey() + "</prompt>");
- }
- }
- }
- out.print("</block>");
- } else if (errors instanceof ActionMessages) {
- out.print("<block>");
- ActionMessages actionMsgs = (ActionMessages) errors;
- if (!actionMsgs.isEmpty()) {
- Iterator iter = actionMsgs.get();
- while (iter.hasNext()) {
- ActionMessage msg = (ActionMessage)iter.next();
- if (msg != null) {
- out.print("<prompt>" + msg.getKey() + "</prompt>");
- }
- }
- }
- out.print("</block>");
- } else if (errors instanceof String[]) {
- out.print("<block>");
- String[] errorsArr = (String []) errors;
- for (int i = 0; i < errorsArr.length; i++) {
- if (errorsArr[i] != null) {
- out.print("<prompt>" + errorsArr[i] + "</prompt>");
- }
- }
- out.print("</block>");
- } else if (errors instanceof String && errors != null) {
- out.print("<block><prompt>" + errors + "</prompt></block>");
- }
+ if (errors == null) {
+ return;
+ } else if (errors instanceof ActionErrors) {
+ // deprecated in Struts 1.2
+ out.print("<block>");
+ ActionErrors actionErrors = (ActionErrors) errors;
+ if (!actionErrors.isEmpty()) {
+ Iterator iter = actionErrors.get();
+ while (iter.hasNext()) {
+ ActionMessage msg = (ActionMessage)iter.next();
+ if (msg != null) {
+ out.print("<prompt>" + msg.getKey() + "</prompt>");
+ }
+ }
+ }
+ out.print("</block>");
+ } else if (errors instanceof ActionMessages) {
+ out.print("<block>");
+ ActionMessages actionMsgs = (ActionMessages) errors;
+ if (!actionMsgs.isEmpty()) {
+ Iterator iter = actionMsgs.get();
+ while (iter.hasNext()) {
+ ActionMessage msg = (ActionMessage)iter.next();
+ if (msg != null) {
+ out.print("<prompt>" + msg.getKey() + "</prompt>");
+ }
+ }
+ }
+ out.print("</block>");
+ } else if (errors instanceof String[]) {
+ out.print("<block>");
+ String[] errorsArr = (String []) errors;
+ for (int i = 0; i < errorsArr.length; i++) {
+ if (errorsArr[i] != null) {
+ out.print("<prompt>" + errorsArr[i] + "</prompt>");
+ }
+ }
+ out.print("</block>");
+ } else if (errors instanceof String && errors != null) {
+ out.print("<block><prompt>" + errors + "</prompt></block>");
+ }
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsSubmitTag.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsSubmitTag.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsSubmitTag.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/core/StrutsSubmitTag.java Wed Aug 10 14:10:59 2005
@@ -56,222 +56,222 @@
* multiple submits this session
*/
public static final String ATTR_VIEWS_MAP = "viewsMap";
- /**
- * Attribute name of key that will be used to retrieve
- * form data for this submission
- */
- public static final String ATTR_VIEWS_MAP_KEY = "key";
-
+ /**
+ * Attribute name of key that will be used to retrieve
+ * form data for this submission
+ */
+ public static final String ATTR_VIEWS_MAP_KEY = "key";
+
// URI to be submitted to the struts ActionServlet
private String submit;
// Namelist to be forwarded to the struts layer
private String namelist;
- // The list of RDCs to be whose state will be "cleared"
- // from the existing session. Must be a space-separated list
- // of "dialogMap" keys.
- private String clearlist;
+ // The list of RDCs to be whose state will be "cleared"
+ // from the existing session. Must be a space-separated list
+ // of "dialogMap" keys.
+ private String clearlist;
// Page context for the RDC data collection
private PageContext context;
- // The "dialogMap" object from the host JSP
- private Map dialogMap;
+ // The "dialogMap" object from the host JSP
+ private Map dialogMap;
- // Error messages (to be i18n'zed)
- private static final String ERR_NO_DIALOGMAP = "<rdc:struts-submit>: The" +
- "\"dialogMap\" attribute must accompany the \"clearlist\"" +
- " attribute; and refer to the dialogMap of the host JSP.";
- private static final String ERR_CANNOT_CLEAR = "Could not clear " +
- "token \"{0}\" specified in <rdc:struts-submit> clearlist. " +
- "Check the clearlist.\n";
- private static final String ERR_POP_FORM_BEAN = "Struts Submit" +
- " Populating Form Bean";
- private static final String ERR_FORWARD_FAILED = "<!-- Error after " +
- "struts submit forward to: \"{0}\" with namelist \"{1}\" -->\n";
- private static final String ERR_ILLEGAL_ACCESS = "IllegalAccessException" +
- " while populating form bean";
- private static final String ERR_ILLEGAL_INVOC = "InvocationTargetException" +
- " while populating form bean";
-
- // Logging
- private static Log log = LogFactory.getLog(StrutsSubmitTag.class);
-
- /*
- * Constructor
- */
+ // Error messages (to be i18n'zed)
+ private static final String ERR_NO_DIALOGMAP = "<rdc:struts-submit>: The" +
+ "\"dialogMap\" attribute must accompany the \"clearlist\"" +
+ " attribute; and refer to the dialogMap of the host JSP.";
+ private static final String ERR_CANNOT_CLEAR = "Could not clear " +
+ "token \"{0}\" specified in <rdc:struts-submit> clearlist. " +
+ "Check the clearlist.\n";
+ private static final String ERR_POP_FORM_BEAN = "Struts Submit" +
+ " Populating Form Bean";
+ private static final String ERR_FORWARD_FAILED = "<!-- Error after " +
+ "struts submit forward to: \"{0}\" with namelist \"{1}\" -->\n";
+ private static final String ERR_ILLEGAL_ACCESS = "IllegalAccessException" +
+ " while populating form bean";
+ private static final String ERR_ILLEGAL_INVOC = "InvocationTargetException" +
+ " while populating form bean";
+
+ // Logging
+ private static Log log = LogFactory.getLog(StrutsSubmitTag.class);
+
+ /*
+ * Constructor
+ */
public StrutsSubmitTag() {
- super();
- this.submit = null;
- this.namelist = null;
- this.clearlist = null;
- this.context = null;
- this.dialogMap = null;
- }
-
- /**
- * Set the submit URI
- *
- * @param String submit
- */
- public void setSubmit(String submit) {
- this.submit = submit;
- }
-
- /**
- * Set the namelist
- *
- * @param String namelist
- */
- public void setNamelist(String namelist) {
- this.namelist = namelist;
- }
-
- /**
- * Set the clearlist
- *
- * @param String clearlist
- */
- public void setClearlist(String clearlist) {
- this.clearlist = clearlist;
- }
-
- /**
- * Set the page context
- *
- * @param PageContext context the supplied page context
- */
- public void setContext(PageContext context) {
- this.context = context;
- }
-
- /**
- * Set the "dialogMap" object [of the host JSP]
- *
- * @param LinkedHashMap the dialogMap object from the host JSP
- */
- public void setDialogMap(Map dialogMap) {
- this.dialogMap = dialogMap;
- }
-
- /**
- * Collect data from the RDC layer and post it into the viewsMap
- * according to the RDC-struts interface contract
- *
- */
+ super();
+ this.submit = null;
+ this.namelist = null;
+ this.clearlist = null;
+ this.context = null;
+ this.dialogMap = null;
+ }
+
+ /**
+ * Set the submit URI
+ *
+ * @param String submit
+ */
+ public void setSubmit(String submit) {
+ this.submit = submit;
+ }
+
+ /**
+ * Set the namelist
+ *
+ * @param String namelist
+ */
+ public void setNamelist(String namelist) {
+ this.namelist = namelist;
+ }
+
+ /**
+ * Set the clearlist
+ *
+ * @param String clearlist
+ */
+ public void setClearlist(String clearlist) {
+ this.clearlist = clearlist;
+ }
+
+ /**
+ * Set the page context
+ *
+ * @param PageContext context the supplied page context
+ */
+ public void setContext(PageContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Set the "dialogMap" object [of the host JSP]
+ *
+ * @param LinkedHashMap the dialogMap object from the host JSP
+ */
+ public void setDialogMap(Map dialogMap) {
+ this.dialogMap = dialogMap;
+ }
+
+ /**
+ * Collect data from the RDC layer and post it into the viewsMap
+ * according to the RDC-struts interface contract
+ *
+ */
public void doTag()
throws IOException, JspException, JspTagException {
JspWriter out = context.getOut();
- if (!RDCUtils.isStringEmpty(namelist)) {
- // (1) Access/create the views map
- Map viewsMap = (Map) context.getSession().
- getAttribute(ATTR_VIEWS_MAP);
- if (viewsMap == null) {
- viewsMap = new HashMap();
- context.getSession().setAttribute(ATTR_VIEWS_MAP, viewsMap);
- }
-
- // (2) Populate form data
- Map formData = new HashMap();
- StringTokenizer nameToks = new StringTokenizer(namelist, " ");
- while (nameToks.hasMoreTokens()) {
- String name = nameToks.nextToken();
- formData.put(name, context.getAttribute(name));
- }
-
- // (3) Store the form data according to the RDC-struts
- // interface contract
- String key = "" + context.hashCode();
- viewsMap.put(key, formData);
- context.getRequest().setAttribute(ATTR_VIEWS_MAP_KEY, key);
- }
-
- if (!RDCUtils.isStringEmpty(clearlist)) {
- // (4) Clear session state based on the clearlist
- if (dialogMap == null) {
- throw new IllegalArgumentException(ERR_NO_DIALOGMAP);
- }
- StringTokenizer clearToks = new StringTokenizer(clearlist, " ");
- outer:
- while (clearToks.hasMoreTokens()) {
- String clearMe = clearToks.nextToken();
- String errMe = clearMe;
- boolean cleared = false;
- int dot = clearMe.indexOf('.');
- if (dot == -1) {
- if(dialogMap.containsKey(errMe)) {
- dialogMap.remove(errMe);
- cleared = true;
- }
- } else {
- // TODO - Nested data model re-initialization
- BaseModel target = null;
- String childId = null;
- while (dot != -1) {
- try {
- childId = clearMe.substring(0,dot);
- if (target == null) {
- target = (BaseModel) dialogMap.get(childId);
- } else {
- if ((target = RDCUtils.getChildDataModel(target,
- childId)) == null) {
- break;
- }
- }
- clearMe = clearMe.substring(dot+1);
- dot = clearMe.indexOf('.');
- } catch (Exception e) {
- MessageFormat msgFormat =
- new MessageFormat(ERR_CANNOT_CLEAR);
- log.warn(msgFormat.format(new Object[] {errMe}));
- continue outer;
- }
- }
- if (target != null) {
- cleared = RDCUtils.clearChildDataModel(target,
- clearMe);
- }
- }
- if (!cleared) {
- MessageFormat msgFormat =
- new MessageFormat(ERR_CANNOT_CLEAR);
- log.warn(msgFormat.format(new Object[] {errMe}));
- }
- }
- }
-
- // (5) Forward request
- try {
- context.forward(submit);
+ if (!RDCUtils.isStringEmpty(namelist)) {
+ // (1) Access/create the views map
+ Map viewsMap = (Map) context.getSession().
+ getAttribute(ATTR_VIEWS_MAP);
+ if (viewsMap == null) {
+ viewsMap = new HashMap();
+ context.getSession().setAttribute(ATTR_VIEWS_MAP, viewsMap);
+ }
+
+ // (2) Populate form data
+ Map formData = new HashMap();
+ StringTokenizer nameToks = new StringTokenizer(namelist, " ");
+ while (nameToks.hasMoreTokens()) {
+ String name = nameToks.nextToken();
+ formData.put(name, context.getAttribute(name));
+ }
+
+ // (3) Store the form data according to the RDC-struts
+ // interface contract
+ String key = "" + context.hashCode();
+ viewsMap.put(key, formData);
+ context.getRequest().setAttribute(ATTR_VIEWS_MAP_KEY, key);
+ }
+
+ if (!RDCUtils.isStringEmpty(clearlist)) {
+ // (4) Clear session state based on the clearlist
+ if (dialogMap == null) {
+ throw new IllegalArgumentException(ERR_NO_DIALOGMAP);
+ }
+ StringTokenizer clearToks = new StringTokenizer(clearlist, " ");
+ outer:
+ while (clearToks.hasMoreTokens()) {
+ String clearMe = clearToks.nextToken();
+ String errMe = clearMe;
+ boolean cleared = false;
+ int dot = clearMe.indexOf('.');
+ if (dot == -1) {
+ if(dialogMap.containsKey(errMe)) {
+ dialogMap.remove(errMe);
+ cleared = true;
+ }
+ } else {
+ // TODO - Nested data model re-initialization
+ BaseModel target = null;
+ String childId = null;
+ while (dot != -1) {
+ try {
+ childId = clearMe.substring(0,dot);
+ if (target == null) {
+ target = (BaseModel) dialogMap.get(childId);
+ } else {
+ if ((target = RDCUtils.getChildDataModel(target,
+ childId)) == null) {
+ break;
+ }
+ }
+ clearMe = clearMe.substring(dot+1);
+ dot = clearMe.indexOf('.');
+ } catch (Exception e) {
+ MessageFormat msgFormat =
+ new MessageFormat(ERR_CANNOT_CLEAR);
+ log.warn(msgFormat.format(new Object[] {errMe}));
+ continue outer;
+ }
+ }
+ if (target != null) {
+ cleared = RDCUtils.clearChildDataModel(target,
+ clearMe);
+ }
+ }
+ if (!cleared) {
+ MessageFormat msgFormat =
+ new MessageFormat(ERR_CANNOT_CLEAR);
+ log.warn(msgFormat.format(new Object[] {errMe}));
+ }
+ }
+ }
+
+ // (5) Forward request
+ try {
+ context.forward(submit);
} catch (ServletException e) {
- // Need to investigate whether refactoring this
- // try to provide blanket coverage makes sense
- MessageFormat msgFormat = new MessageFormat(ERR_FORWARD_FAILED);
- // Log error and send error message to JspWriter
- out.write(msgFormat.format(new Object[] {submit, namelist}));
- log.error(msgFormat.format(new Object[] {submit, namelist}));
+ // Need to investigate whether refactoring this
+ // try to provide blanket coverage makes sense
+ MessageFormat msgFormat = new MessageFormat(ERR_FORWARD_FAILED);
+ // Log error and send error message to JspWriter
+ out.write(msgFormat.format(new Object[] {submit, namelist}));
+ log.error(msgFormat.format(new Object[] {submit, namelist}));
} // end of try-catch
}
- /**
- * Retrieve data posted to viewsMap for this request according to the
- * RDC-struts interface contract, and populate the ActionForm using
- * this data.
- *
- */
+ /**
+ * Retrieve data posted to viewsMap for this request according to the
+ * RDC-struts interface contract, and populate the ActionForm using
+ * this data.
+ *
+ */
public static void populate(ActionForm formBean, HttpServletRequest req,
- ActionErrors errors) {
+ ActionErrors errors) {
- Map viewsMap = (Map) req.getSession().getAttribute(ATTR_VIEWS_MAP);
- Map formData = (Map) viewsMap.get(req.getAttribute(ATTR_VIEWS_MAP_KEY));
+ Map viewsMap = (Map) req.getSession().getAttribute(ATTR_VIEWS_MAP);
+ Map formData = (Map) viewsMap.get(req.getAttribute(ATTR_VIEWS_MAP_KEY));
- try {
- BeanUtils.populate(formBean, formData);
- } catch (IllegalAccessException iae) {
- log.error(ERR_ILLEGAL_ACCESS);
- errors.add(ERR_POP_FORM_BEAN, new ActionMessage(ERR_ILLEGAL_ACCESS));
- } catch (InvocationTargetException ite) {
- log.error(ERR_ILLEGAL_INVOC);
- errors.add(ERR_POP_FORM_BEAN, new ActionMessage(ERR_ILLEGAL_INVOC));
- }
+ try {
+ BeanUtils.populate(formBean, formData);
+ } catch (IllegalAccessException iae) {
+ log.error(ERR_ILLEGAL_ACCESS);
+ errors.add(ERR_POP_FORM_BEAN, new ActionMessage(ERR_ILLEGAL_ACCESS));
+ } catch (InvocationTargetException ite) {
+ log.error(ERR_ILLEGAL_INVOC);
+ errors.add(ERR_POP_FORM_BEAN, new ActionMessage(ERR_ILLEGAL_INVOC));
+ }
}
}
Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/Conditions.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/Conditions.java?rev=231329&r1=231328&r2=231329&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/Conditions.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/dm/Conditions.java Wed Aug 10 14:10:59 2005
@@ -34,140 +34,140 @@
*/
public class Conditions {
- // Error messages (to be i18n'zed)
- private static final String ERR_BAD_EXPR = "Error evaluating " +
- "expression; received error message: \"{0}\"\n";
-
- // Logging
- private static Log log = LogFactory.getLog(Conditions.class);
-
- /**
- * Java Object corresponding to an individual match condition
- * defined within a rule in the XML navigation rules structure
- * for the rule based directed dialog.
- *
- * Target will be chosen if the lvalue matches rvalue.
- *
- * Corresponds to <match> element in XML navigation rules.
- *
- * @author Rahul Akolkar
- */
- public static class Match extends RuleBasedDirectedDialog.ConditionImpl {
- public Match() {
- operation = "equal-to";
- }
- public static Map getAttrPropMap() {
- Map attrPropMap = new HashMap();
- attrPropMap.put("lvalue", "lvalue");
- attrPropMap.put("rvalue", "rvalue");
- attrPropMap.put("target", "target");
- return attrPropMap;
- }
- }
-
- /**
- * Java Object corresponding to an individual when condition
- * defined within a rule in the XML navigation rules structure
- * for the rule based directed dialog.
- *
- * Target will be chosen if the test succeeds.
- *
- * Corresponds to <when> element in XML navigation rules.
- *
- * @author Rahul Akolkar
- */
- public static class When extends RuleBasedDirectedDialog.ConditionImpl {
- public When() {
- operation = "equal-to";
- rvalue = "true";
- }
- public static Map getAttrPropMap() {
- Map attrPropMap = new HashMap();
- attrPropMap.put("test", "lvalue");
- attrPropMap.put("target", "target");
- return attrPropMap;
- }
- }
-
- /**
- * Java Object corresponding to an individual unless condition
- * defined within a rule in the XML navigation rules structure
- * for the rule based directed dialog.
- *
- * Target will be chosen if the test fails.
- *
- * Corresponds to <unless> element in XML navigation rules.
- *
- * @author Rahul Akolkar
- */
- public static class Unless extends RuleBasedDirectedDialog.ConditionImpl {
- public Unless() {
- operation = "equal-to";
- rvalue = "false";
- }
- public static Map getAttrPropMap() {
- Map attrPropMap = new HashMap();
- attrPropMap.put("test", "lvalue");
- attrPropMap.put("target", "target");
- return attrPropMap;
- }
- }
-
- /**
- * Java Object corresponding to an individual match-attribute condition
- * defined within a rule in the XML navigation rules structure
- * for the rule based directed dialog.
- *
- * Target will be chosen if the value of the specified attribute of the
- * specified matches rvalue.
- *
- * Corresponds to <match-attribute> element in XML navigation rules.
- *
- * @author Rahul Akolkar
- */
- public static class MatchAttribute extends
- RuleBasedDirectedDialog.ConditionImpl {
+ // Error messages (to be i18n'zed)
+ private static final String ERR_BAD_EXPR = "Error evaluating " +
+ "expression; received error message: \"{0}\"\n";
+
+ // Logging
+ private static Log log = LogFactory.getLog(Conditions.class);
+
+ /**
+ * Java Object corresponding to an individual match condition
+ * defined within a rule in the XML navigation rules structure
+ * for the rule based directed dialog.
+ *
+ * Target will be chosen if the lvalue matches rvalue.
+ *
+ * Corresponds to <match> element in XML navigation rules.
+ *
+ * @author Rahul Akolkar
+ */
+ public static class Match extends RuleBasedDirectedDialog.ConditionImpl {
+ public Match() {
+ operation = "equal-to";
+ }
+ public static Map getAttrPropMap() {
+ Map attrPropMap = new HashMap();
+ attrPropMap.put("lvalue", "lvalue");
+ attrPropMap.put("rvalue", "rvalue");
+ attrPropMap.put("target", "target");
+ return attrPropMap;
+ }
+ }
+
+ /**
+ * Java Object corresponding to an individual when condition
+ * defined within a rule in the XML navigation rules structure
+ * for the rule based directed dialog.
+ *
+ * Target will be chosen if the test succeeds.
+ *
+ * Corresponds to <when> element in XML navigation rules.
+ *
+ * @author Rahul Akolkar
+ */
+ public static class When extends RuleBasedDirectedDialog.ConditionImpl {
+ public When() {
+ operation = "equal-to";
+ rvalue = "true";
+ }
+ public static Map getAttrPropMap() {
+ Map attrPropMap = new HashMap();
+ attrPropMap.put("test", "lvalue");
+ attrPropMap.put("target", "target");
+ return attrPropMap;
+ }
+ }
+
+ /**
+ * Java Object corresponding to an individual unless condition
+ * defined within a rule in the XML navigation rules structure
+ * for the rule based directed dialog.
+ *
+ * Target will be chosen if the test fails.
+ *
+ * Corresponds to <unless> element in XML navigation rules.
+ *
+ * @author Rahul Akolkar
+ */
+ public static class Unless extends RuleBasedDirectedDialog.ConditionImpl {
+ public Unless() {
+ operation = "equal-to";
+ rvalue = "false";
+ }
+ public static Map getAttrPropMap() {
+ Map attrPropMap = new HashMap();
+ attrPropMap.put("test", "lvalue");
+ attrPropMap.put("target", "target");
+ return attrPropMap;
+ }
+ }
+
+ /**
+ * Java Object corresponding to an individual match-attribute condition
+ * defined within a rule in the XML navigation rules structure
+ * for the rule based directed dialog.
+ *
+ * Target will be chosen if the value of the specified attribute of the
+ * specified matches rvalue.
+ *
+ * Corresponds to <match-attribute> element in XML navigation rules.
+ *
+ * @author Rahul Akolkar
+ */
+ public static class MatchAttribute extends
+ RuleBasedDirectedDialog.ConditionImpl {
- private String element = null;
- private String name = null;
- public MatchAttribute() {
- operation = "equal-to";
- }
- public static Map getAttrPropMap() {
- Map attrPropMap = new HashMap();
- attrPropMap.put("element", "element");
- attrPropMap.put("name", "name");
- attrPropMap.put("value", "rvalue");
- return attrPropMap;
- }
- public String getElement() {
- return element;
- }
- public void setElement(String element) {
- this.element = element;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public void pre() {
- Element elem = null;
- String attr = null;
- try {
- elem = (Element) DMUtils.proprietaryEval(groupTag, groupModel,
- element, Element.class, lruCache, tempVars);
- attr = (String) DMUtils.proprietaryEval(groupTag, groupModel,
- name, String.class, lruCache, tempVars);
- } catch (Exception e) {
- MessageFormat msgFormat = new MessageFormat(ERR_BAD_EXPR);
- log.error(msgFormat.format(new Object[] {e.getMessage()}), e);
- }
- if (elem != null && elem.hasAttribute(attr)) {
- lvalue = elem.getAttribute(attr);
- }
- }
- }
+ private String element = null;
+ private String name = null;
+ public MatchAttribute() {
+ operation = "equal-to";
+ }
+ public static Map getAttrPropMap() {
+ Map attrPropMap = new HashMap();
+ attrPropMap.put("element", "element");
+ attrPropMap.put("name", "name");
+ attrPropMap.put("value", "rvalue");
+ return attrPropMap;
+ }
+ public String getElement() {
+ return element;
+ }
+ public void setElement(String element) {
+ this.element = element;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public void pre() {
+ Element elem = null;
+ String attr = null;
+ try {
+ elem = (Element) DMUtils.proprietaryEval(groupTag, groupModel,
+ element, Element.class, lruCache, tempVars);
+ attr = (String) DMUtils.proprietaryEval(groupTag, groupModel,
+ name, String.class, lruCache, tempVars);
+ } catch (Exception e) {
+ MessageFormat msgFormat = new MessageFormat(ERR_BAD_EXPR);
+ log.error(msgFormat.format(new Object[] {e.getMessage()}), e);
+ }
+ if (elem != null && elem.hasAttribute(attr)) {
+ lvalue = elem.getAttribute(attr);
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org