/** * {@inheritDoc} */ @Override public Object getFwkAttribute(final String name) { return backing.getFwkAttribute(name); }
@Test public void testFwkAttributeAccessors() { UIContext uic = createUIContext(); String key = "key"; String value = "value"; uic.setFwkAttribute(key, value); Assert.assertEquals("Incorrect fwk attribute value returned", value, uic. getFwkAttribute(key)); uic.removeFwkAttribute(key); Assert.assertNull("Fwk attribute should be null after being removed", uic.getFwkAttribute( key)); String key2 = "key2"; String value2 = "value2"; uic.setFwkAttribute(key, value); uic.setFwkAttribute(key2, value2); Assert.assertEquals("Incorrect number of fwk attributes returned", 2, uic. getFwkAttributeNames().size()); Assert.assertTrue("The test key is not in the user context", uic.getFwkAttributeNames(). contains(key)); Assert.assertTrue("The second test key is not in the user context", uic. getFwkAttributeNames().contains(key2)); }
/** * @return the registered subordinate controls or null */ public static Set<String> getRegisteredSubordinateControls() { UIContext uic = UIContextHolder.getCurrentPrimaryUIContext(); return uic == null ? null : (Set<String>) uic.getFwkAttribute(SUBORDINATE_CONTROL_SESSION_KEY); }
/** * * @return the registered AJAX operations for this user context or null */ public static Map<String, AjaxOperation> getRegisteredOperations() { UIContext uic = UIContextHolder.getCurrentPrimaryUIContext(); return uic == null ? null : (Map<String, AjaxOperation>) uic.getFwkAttribute(AJAX_OPERATIONS_SESSION_KEY); }
/** * Register the Subordinate Control so that it can be applied by the {@link SubordinateControlInterceptor}. * * @param controlId the subordinate id */ public static void registerSubordinateControl(final String controlId) { UIContext uic = UIContextHolder.getCurrentPrimaryUIContext(); if (uic == null) { throw new SystemException("No User Context available to register Subordinate Control."); } Set<String> controls = (Set<String>) uic.getFwkAttribute(SUBORDINATE_CONTROL_SESSION_KEY); if (controls == null) { controls = new HashSet<>(); uic.setFwkAttribute(SUBORDINATE_CONTROL_SESSION_KEY, controls); } controls.add(controlId); }
/** * The Ajax servlet needs access to the AjaxOperation Store the operation in the user context using the trigger Id, * as this will be present in the Servlet HttpRequest. agreed key. The ajax id is passed in the url to the servlet * so it can then access the context. * * @param operation the operation to register. */ private static void registerAjaxOperation(final AjaxOperation operation) { UIContext uic = UIContextHolder.getCurrentPrimaryUIContext(); if (uic == null) { throw new SystemException("No User Context Available to Register AJAX Operations."); } Map<String, AjaxOperation> operations = (Map<String, AjaxOperation>) uic.getFwkAttribute(AJAX_OPERATIONS_SESSION_KEY); if (operations == null) { operations = new HashMap<>(); uic.setFwkAttribute(AJAX_OPERATIONS_SESSION_KEY, operations); } operations.put(operation.getTriggerId(), operation); } }
boolean treeDumped = "true".equalsIgnoreCase((String) uic.getFwkAttribute( UICONTEXT_TREE_DUMPED_KEY));