本文整理汇总了Java中org.kuali.rice.krad.web.form.UifFormManager类的典型用法代码示例。如果您正苦于以下问题:Java UifFormManager类的具体用法?Java UifFormManager怎么用?Java UifFormManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UifFormManager类属于org.kuali.rice.krad.web.form包,在下文中一共展示了UifFormManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterCompletion
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* After the view is rendered remove the view to reduce the size of the form storage in memory.
*
* {@inheritDoc}
*/
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) throws Exception {
ProcessLogger.trace("after-completion");
UifFormManager uifFormManager = (UifFormManager) request.getSession().getAttribute(UifParameters.FORM_MANAGER);
UifFormBase uifForm = (UifFormBase) request.getAttribute(UifConstants.REQUEST_FORM);
if ((uifForm == null) || (uifForm.getView() == null)) {
return;
}
// remove the session transient variables from the request form before adding it to the list of
// Uif session forms
boolean persistFormToSession = uifForm.getView().isPersistFormToSession();
if (persistFormToSession && (uifFormManager != null)) {
uifFormManager.purgeForm(uifForm);
uifFormManager.addSessionForm(uifForm);
}
uifForm.setView(null);
ProcessLogger.trace("after-completion-end");
}
示例2: setUp
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
request = new MockHttpServletRequest();
request.setMethod("POST");
UifFormManager uifFormManager = new UifFormManager();
String formKey = "TEST";
model = new TestForm();
model.setFormKey(formKey);
uifFormManager.addSessionForm(model);
request.getSession().setAttribute(UifParameters.FORM_MANAGER, uifFormManager);
request.setParameter(UifParameters.FORM_KEY, formKey);
handlerInterceptor = new UifControllerHandlerInterceptor();
controller = new MockController();
}
示例3: setupMockRequest
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
protected MockHttpServletRequest setupMockRequest() {
MockHttpServletRequest request = new MockHttpServletRequest();
RequestContextHolder.setRequestAttributes(new ServletWebRequest(request));
UifFormManager formManager = new UifFormManager();
request.getSession().setAttribute(UifParameters.FORM_MANAGER, formManager);
return request;
}
示例4: checkForMethodAccess
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Checks whether access to the handler method is allowed based available methods or accessible methods
* on view configuration.
*
* <p>Since this method is invoked before the request form is setup, we need to retrieve the session form
* form the form manager. In the case of missing post data (GET requests), view method access is not
* granted.</p>
*
* @param request HTTP request to retrieve parameters from
* @return boolean true if method access is allowed based on the view, false if not
*/
protected boolean checkForMethodAccess(HttpServletRequest request) {
String methodToCall = request.getParameter(UifParameters.METHOD_TO_CALL);
// if method to call is blank, we will assume they are using other strategies to map controller
// methods, and therefore using custom access management
if (StringUtils.isBlank(methodToCall)) {
return true;
}
UifFormManager uifFormManager = (UifFormManager) request.getSession().getAttribute(UifParameters.FORM_MANAGER);
UifFormBase form = null;
String formKeyParam = request.getParameter(UifParameters.FORM_KEY);
if (StringUtils.isNotBlank(formKeyParam) && (uifFormManager != null)) {
form = uifFormManager.getSessionForm(formKeyParam);
}
// if we don't have the view post data, there is nothing to validate
if ((form == null) || (form.getViewPostMetadata() == null)) {
return true;
}
// if the method to call is listed as a method in either the available methods to call or the
// view's accessible methods to call, then return true
return !form.getViewPostMetadata().getAvailableMethodToCalls().contains(methodToCall) || ((form
.getViewPostMetadata().getAccessibleMethodToCalls() != null) && form.getViewPostMetadata()
.getAccessibleMethodToCalls().contains(methodToCall));
}
示例5: tableJsonRetrieval
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Get method for getting aaData for jquery datatables which are using sAjaxSource option.
*
* <p>This will return
* the aaData generated by the RichTable widget of the matching table matched by the tableId passed in
* request parameters on the matching form by formKey.</p>
*
* @param form the form (not used, the most up to date form is retrieved from the form manager in session)
* @param result binding result
* @param request http request
* @param response http response
* @return json content containing an aaData array of arrays row content to consumed by datatables plugin
*/
@RequestMapping(method = RequestMethod.GET, params = "methodToCall=tableJsonRetrieval")
@ResponseBody
public String tableJsonRetrieval(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
HttpServletRequest request, HttpServletResponse response) {
UifFormManager uifFormManager = (UifFormManager) request.getSession().getAttribute(UifParameters.FORM_MANAGER);
String formKey = request.getParameter(UifParameters.FORM_KEY);
String tableId = request.getParameter(UifParameters.TABLE_ID);
UifFormBase currentForm = uifFormManager.getSessionForm(formKey);
ViewIndex viewIndex = currentForm.getPostedView().getViewIndex();
Component component = viewIndex.getComponentById(tableId);
String aaData = "{ \"" + UifConstants.TableToolsKeys.AA_DATA + "\" : ";
if (component != null
&& component instanceof CollectionGroup
&& ((CollectionGroup) component).getLayoutManager() != null
&& ((CollectionGroup) component).getLayoutManager() instanceof TableLayoutManager) {
CollectionGroup collectionGroup = (CollectionGroup) component;
aaData = aaData +
((TableLayoutManager) collectionGroup.getLayoutManager()).getRichTable().getAaData() + "}";
} else {
aaData = aaData + "[]}";
}
return aaData;
}
示例6: removeUnusedBreadcrumbs
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Remove unused forms from breadcrumb history
*
* <p>
* When going back in the breadcrumb history some forms become unused in the breadcrumb history. Here the unused
* forms are being determine and removed from the server to free memory.
* </p>
*
* @param uifFormManager
* @param formKey of the current form
* @param lastFormKey of the last form
*/
public static void removeUnusedBreadcrumbs(UifFormManager uifFormManager, String formKey, String lastFormKey) {
if (StringUtils.isBlank(formKey) || StringUtils.isBlank(lastFormKey) || StringUtils.equals(formKey,
lastFormKey)) {
return;
}
UifFormBase previousForm = uifFormManager.getSessionForm(lastFormKey);
if (previousForm == null) {
return;
}
uifFormManager.removeSessionFormByKey(lastFormKey);
}
示例7: testModifiedPropertyTracking
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
@Test
public void testModifiedPropertyTracking() {
MaintenanceDocumentForm form = buildMaintenanceDocumentForm();
ViewPostMetadata viewPostMetadata = new ViewPostMetadata();
form.setViewPostMetadata(viewPostMetadata);
MaintenanceDocumentBase maintDoc = (MaintenanceDocumentBase)form.getDocument();
UifServletRequestDataBinder binder = new UifServletRequestDataBinder(form, "form");
// turn off auto linking for this test
binder.setAutoLinking(false);
MockHttpServletRequest request = new MockHttpServletRequest();
RequestContextHolder.setRequestAttributes(new ServletWebRequest(request));
UifFormManager formManager = new UifFormManager();
request.getSession().setAttribute(UifParameters.FORM_MANAGER, formManager);
String basePath = "document.newMaintainableObject.dataObject.";
String idPath = basePath + "id";
String titlePath = basePath + "sessionTitle";
String altCoordinator1IdPath = basePath + "altCoordinator1Id";
String altCoordinator1_idPath = basePath + "altCoordinator1.id";
addAccessibleRequestParameter(idPath, "12345", request, viewPostMetadata);
addAccessibleRequestParameter(titlePath, "My New ConferenceSession", request, viewPostMetadata);
addAccessibleRequestParameter(altCoordinator1IdPath, null, request, viewPostMetadata);
addAccessibleRequestParameter(altCoordinator1_idPath, "1", request, viewPostMetadata);
// now let's run the binding and make sure it bound correctly
binder.bind(request);
// verify that it performed proper binding
ConferenceSession session = (ConferenceSession)maintDoc.getNewMaintainableObject().getDataObject();
assertEquals("12345", session.getId());
assertEquals("My New ConferenceSession", session.getSessionTitle());
assertNull(session.getAltCoordinator1Id());
assertNotNull(session.getAltCoordinator1());
assertEquals(Long.valueOf(1), session.getAltCoordinator1().getId());
assertTrue(session.getAltCoordinator1().getAltCoordinatedSessions1().isEmpty());
// finally, let's ensure it tracked the appropriate modified properties
UifBeanPropertyBindingResult result = (UifBeanPropertyBindingResult)binder.getInternalBindingResult();
Set<String> modifiedPaths = result.getModifiedPaths();
// should contain these paths
assertTrue(modifiedPaths.contains(idPath));
assertTrue(modifiedPaths.contains(titlePath));
assertTrue(modifiedPaths.contains(altCoordinator1_idPath));
// should not contain the altCoordinator1Id path since we didn't actually change it's value
assertFalse(modifiedPaths.contains(altCoordinator1IdPath));
// total number of modified paths should be 3
assertEquals(3, modifiedPaths.size());
// Now let's rebind the same requests, there should be no modified paths this time
// create a new binder first
binder = new UifServletRequestDataBinder(form, "form");
binder.bind(request);
result = (UifBeanPropertyBindingResult)binder.getInternalBindingResult();
modifiedPaths = result.getModifiedPaths();
assertEquals(0, modifiedPaths.size());
// now let's make a minor change to the amId
binder = new UifServletRequestDataBinder(form, "form");
request.setParameter(altCoordinator1IdPath, "2");
binder.bind(request);
// check the account, then the modified paths
assertEquals(Long.valueOf(2), session.getAltCoordinator1Id());
result = (UifBeanPropertyBindingResult)binder.getInternalBindingResult();
modifiedPaths = result.getModifiedPaths();
assertEquals(1, modifiedPaths.size());
assertTrue(modifiedPaths.contains(altCoordinator1IdPath));
}
示例8: doFilter
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Checks for a session timeout and if one has occurred pulls the view session policy to determine whether
* a redirect needs to happen
*
* <p>
* To determine whether a session timeout has occurred, the filter looks for the existence of a request parameter
* named {@link org.kuali.rice.krad.uif.UifParameters#SESSION_ID}. If found it then compares that id to the id
* on the current session. If they are different, or a session does not currently exist a timeout is assumed.
*
* In addition, if a request was made for a form key and the view has session storage enabled, a check is made
* to verify the form manager contains a session form. If not this is treated like a session timeout
* </p>
*
* <p>
* If a timeout has occurred an attempt is made to resolve a view from the request (based on the view id or
* type parameters), then the associated {@link ViewSessionPolicy} is pulled which indicates how the timeout should
* be handled. This either results in doing a redirect or nothing
* </p>
*
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
* javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filerChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpSession httpSession = (httpServletRequest).getSession(false);
boolean timeoutOccurred = false;
// compare session id in request to id on current session, if different or a session does not exist
// then assume a session timeout has occurred
if (request.getParameter(UifParameters.SESSION_ID) != null) {
String requestedSessionId = request.getParameter(UifParameters.SESSION_ID);
if ((httpSession == null) || !StringUtils.equals(httpSession.getId(), requestedSessionId)) {
timeoutOccurred = true;
}
}
String viewId = getViewIdFromRequest(httpServletRequest);
if (StringUtils.isBlank(viewId)) {
// can't retrieve a session policy if view id was not passed
filerChain.doFilter(request, response);
return;
}
// check for requested form key for a POST and if found and session storage is enabled for the
// view, verify the form is present in the form manager
boolean isGetRequest = RequestMethod.GET.name().equals(httpServletRequest.getMethod());
String formKeyParam = request.getParameter(UifParameters.FORM_KEY);
if (StringUtils.isNotBlank(formKeyParam) && !isGetRequest && getViewDictionaryService().isSessionStorageEnabled(
viewId) && (httpSession != null)) {
UifFormManager uifFormManager = (UifFormManager) httpSession.getAttribute(UifParameters.FORM_MANAGER);
// if session form not found, treat like a session timeout
if ((uifFormManager != null) && !uifFormManager.hasSessionForm(formKeyParam)) {
timeoutOccurred = true;
}
}
// if no timeout occurred continue filter chain
if (!timeoutOccurred) {
filerChain.doFilter(request, response);
return;
}
// retrieve timeout policy associated with the view to determine what steps to take
ViewSessionPolicy sessionPolicy = getViewDictionaryService().getViewSessionPolicy(viewId);
if (sessionPolicy.isRedirectToHome() || StringUtils.isNotBlank(sessionPolicy.getRedirectUrl()) || sessionPolicy
.isRenderTimeoutView()) {
String redirectUrl = getRedirectUrl(sessionPolicy, httpServletRequest);
sendRedirect(httpServletRequest, (HttpServletResponse) response, redirectUrl);
}
}
示例9: afterCompletion
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* After the view is rendered we can do some cleaning to reduce the size of the form storage in memory
*
* @see org.springframework.web.servlet.HandlerInterceptor#afterCompletion(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object, java.lang.Exception)
*/
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
Exception ex) throws Exception {
UifFormManager uifFormManager = (UifFormManager) request.getSession().getAttribute(UifParameters.FORM_MANAGER);
UifFormBase uifForm = (UifFormBase) request.getAttribute(UifConstants.REQUEST_FORM);
if ((uifForm == null) || (uifForm.getView() == null && uifForm.getPostedView() == null)) {
return;
}
// perform form session handling
boolean persistFormToSession = uifForm.getView() != null ? uifForm.getView().isPersistFormToSession() :
uifForm.getPostedView().isPersistFormToSession();
// cleaning of view structure
if (uifForm.isRequestRedirected() || uifForm.isUpdateNoneRequest()) {
// view wasn't rendered, just set to null and leave previous posted view
uifForm.setView(null);
} else if (uifForm.isUpdateViewRequest() || uifForm.isUpdateDialogRequest()) {
// partial refresh on posted view
View postedView = uifForm.getPostedView();
if (postedView != null) {
postedView.getViewHelperService().cleanViewAfterRender(postedView);
}
} else {
// full view render
View view = uifForm.getView();
if (view != null) {
view.getViewHelperService().cleanViewAfterRender(view);
}
uifForm.setPostedView(view);
uifForm.setView(null);
}
// remove the session transient variables from the request form before adding it to the list of
// Uif session forms
if (persistFormToSession && (uifFormManager != null)) {
uifFormManager.purgeForm(uifForm);
uifFormManager.addSessionForm(uifForm);
}
}
示例10: doFilter
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Checks for a session timeout and if one has occurred pulls the view session policy to determine whether
* a redirect needs to happen
*
* <p>
* To determine whether a session timeout has occurred, the filter looks for the existence of a request parameter
* named {@link org.kuali.rice.krad.uif.UifParameters#SESSION_ID}. If found it then compares that id to the id
* on the current session. If they are different, or a session does not currently exist a timeout is assumed.
*
* In addition, if a request was made for a form key and the view has session storage enabled, a check is made
* to verify the form manager contains a session form. If not this is treated like a session timeout
* </p>
*
* <p>
* If a timeout has occurred an attempt is made to resolve a view from the request (based on the view id or
* type parameters), then the associated {@link ViewSessionPolicy} is pulled which indicates how the timeout should
* be handled. This either results in doing a redirect or nothing
* </p>
*
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
* javax.servlet.FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filerChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpSession httpSession = (httpServletRequest).getSession(false);
boolean timeoutOccurred = false;
// compare session id in request to id on current session, if different or a session does not exist
// then assume a session timeout has occurred
if (request.getParameter(UifParameters.SESSION_ID) != null) {
String requestedSessionId = request.getParameter(UifParameters.SESSION_ID);
if ((httpSession == null) || !StringUtils.equals(httpSession.getId(), requestedSessionId)) {
timeoutOccurred = true;
}
}
String viewId = UifControllerHelper.getViewIdFromRequest(httpServletRequest);
if (StringUtils.isBlank(viewId)) {
// can't retrieve a session policy if view id was not passed
filerChain.doFilter(request, response);
return;
}
// check for requested form key for a POST and if found and session storage is enabled for the
// view, verify the form is present in the form manager
boolean isGetRequest = RequestMethod.GET.name().equals(httpServletRequest.getMethod());
String formKeyParam = request.getParameter(UifParameters.FORM_KEY);
if (StringUtils.isNotBlank(formKeyParam) && !isGetRequest && getViewDictionaryService().isSessionStorageEnabled(
viewId) && (httpSession != null)) {
UifFormManager uifFormManager = (UifFormManager) httpSession.getAttribute(UifParameters.FORM_MANAGER);
// if session form not found, treat like a session timeout
if ((uifFormManager != null) && !uifFormManager.hasSessionForm(formKeyParam)) {
timeoutOccurred = true;
}
}
// if no timeout occurred continue filter chain
if (!timeoutOccurred) {
filerChain.doFilter(request, response);
return;
}
// retrieve timeout policy associated with the view to determine what steps to take
ViewSessionPolicy sessionPolicy = getViewDictionaryService().getViewSessionPolicy(viewId);
if (sessionPolicy.isRedirectToHome() || StringUtils.isNotBlank(sessionPolicy.getRedirectUrl()) || sessionPolicy
.isRenderTimeoutView()) {
String redirectUrl = getRedirectUrl(sessionPolicy, httpServletRequest);
sendRedirect(httpServletRequest, (HttpServletResponse) response, redirectUrl);
}
}
示例11: getUifFormManager
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Retrieves the {@link org.kuali.rice.krad.web.form.UifFormManager} which can be used to store and remove forms
* from the session
*
* @return UifFormManager
*/
public static UifFormManager getUifFormManager() {
GlobalVariables vars = getCurrentGlobalVariables();
return vars.uifFormManager;
}
示例12: setUifFormManager
import org.kuali.rice.krad.web.form.UifFormManager; //导入依赖的package包/类
/**
* Sets a {@link org.kuali.rice.krad.web.form.UifFormManager} for the current thread
*
* @param uifFormManager
*/
public static void setUifFormManager(UifFormManager uifFormManager) {
GlobalVariables vars = getCurrentGlobalVariables();
vars.uifFormManager = uifFormManager;
}