use of org.kuali.kfs.kns.web.struts.form.KualiForm in project cu-kfs by CU-CommunityApps.
the class WebUtils method parseMethodToCall.
/**
* Checks for methodToCall parameter, and picks off the value using set dot
* notation. Handles the problem of image submits.
*
* @param request
* @return methodToCall String
*/
public static String parseMethodToCall(ActionForm form, HttpServletRequest request) {
String methodToCall = null;
// check if is specified cleanly
if (StringUtils.isNotBlank(request.getParameter(KRADConstants.DISPATCH_REQUEST_PARAMETER))) {
if (form instanceof KualiForm && !((KualiForm) form).shouldMethodToCallParameterBeUsed(KRADConstants.DISPATCH_REQUEST_PARAMETER, request.getParameter(KRADConstants.DISPATCH_REQUEST_PARAMETER), request)) {
throw new RuntimeException("Cannot verify that the methodToCall should be " + request.getParameter(KRADConstants.DISPATCH_REQUEST_PARAMETER));
}
methodToCall = request.getParameter(KRADConstants.DISPATCH_REQUEST_PARAMETER);
// include .x at the end of the parameter to make it consistent w/
// other parameters
request.setAttribute(KRADConstants.METHOD_TO_CALL_ATTRIBUTE, KRADConstants.DISPATCH_REQUEST_PARAMETER + "." + methodToCall + IMAGE_COORDINATE_CLICKED_X_EXTENSION);
}
/**
* The reason why we are checking for a ".x" at the end of the parameter
* name: It is for the image names that in addition to sending the form
* data, the web browser sends the x,y coordinate of where the user
* clicked on the image. If the image input is not given a name then the
* browser sends the x and y coordinates as the "x" and "y" input
* fields. If the input image does have a name, the x and y coordinates
* are sent using the format name.x and name.y.
*/
if (methodToCall == null) {
// iterate through parameters looking for methodToCall
for (Enumeration i = request.getParameterNames(); i.hasMoreElements(); ) {
String parameterName = (String) i.nextElement();
// check if the parameter name is a specifying the methodToCall
if (isMethodToCall(parameterName)) {
methodToCall = getMethodToCallSettingAttribute(form, request, parameterName);
break;
} else {
// just the name)
for (String value : request.getParameterValues(parameterName)) {
// confused with methodToCallFoobar
if (isMethodToCall(value)) {
methodToCall = getMethodToCallSettingAttribute(form, request, value);
// why is there not a break outer loop here?
}
}
}
}
}
return methodToCall;
}
use of org.kuali.kfs.kns.web.struts.form.KualiForm in project cu-kfs by CU-CommunityApps.
the class CapitalAssetInformationActionBase method setTabStatesForCapitalAssets.
/**
* sets the capital assets screens for create and modify and accounting lines
* for capitalization screen as open. If accounting lines for capitalizataion list is
* not empty then set "Accounting Lines for Capitalization" tab to open else set to close.
* If capital asset with capital asset action indicator = 'C' then set "Create Capital Asset"
* tab to open else set to close
* If capital asset with capital asset action indicator = 'M' then set "Modify Capital Asset"
* tab to open else set to close
*
* @param form
*/
protected void setTabStatesForCapitalAssets(ActionForm form) {
KualiForm kualiForm = (KualiForm) form;
CapitalAccountingLinesFormBase capitalAccountingLinesFormBase = (CapitalAccountingLinesFormBase) form;
Map<String, String> tabStates = kualiForm.getTabStates();
Map<String, String> newTabStates = new HashMap<String, String>();
CapitalAssetInformationFormBase capitalAssetInformationFormBase = (CapitalAssetInformationFormBase) form;
CapitalAccountingLinesDocumentBase caldb = (CapitalAccountingLinesDocumentBase) capitalAssetInformationFormBase.getFinancialDocument();
// generated tab key for the three tabs
String tabIdForAccountingLinesForCapitalization = WebUtils.generateTabKey(KFSConstants.CapitalAssets.ACCOUNTING_LINES_FOR_CAPITALIZATION_TAB_TITLE);
String tabIdForCreateCapitalAsset = WebUtils.generateTabKey(KFSConstants.CapitalAssets.CREATE_CAPITAL_ASSETS_TAB_TITLE);
String tabIdForModifyCapitalAsset = WebUtils.generateTabKey(KFSConstants.CapitalAssets.MODIFY_CAPITAL_ASSETS_TAB_TITLE);
tabStates.remove(tabIdForAccountingLinesForCapitalization);
tabStates.remove(tabIdForCreateCapitalAsset);
tabStates.remove(tabIdForModifyCapitalAsset);
// if there are any capital accounting lines for capitalization exists then
if (caldb.getCapitalAccountingLines().size() > 0 || caldb.isCapitalAccountingLinesExist()) {
tabStates.put(tabIdForAccountingLinesForCapitalization, KFSConstants.CapitalAssets.CAPITAL_ASSET_TAB_STATE_OPEN);
} else {
tabStates.put(tabIdForAccountingLinesForCapitalization, KFSConstants.CapitalAssets.CAPITAL_ASSET_TAB_STATE_CLOSE);
}
if (checkCreateAssetsExist(capitalAccountingLinesFormBase)) {
tabStates.put(tabIdForCreateCapitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_TAB_STATE_OPEN);
} else {
tabStates.put(tabIdForCreateCapitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_TAB_STATE_CLOSE);
}
if (checkModifyAssetsExist(capitalAccountingLinesFormBase)) {
tabStates.put(tabIdForModifyCapitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_TAB_STATE_OPEN);
} else {
tabStates.put(tabIdForModifyCapitalAsset, KFSConstants.CapitalAssets.CAPITAL_ASSET_TAB_STATE_CLOSE);
}
kualiForm.setTabStates(tabStates);
}
Aggregations