/** * <p> * Indicates whether this list was present in the request. * </p> * <p> * Lists that allow no option to be selected have a hidden input field, whose name is name-h to indicate that it is * in the request. * </p> * * @param request the request being responded to. * @return true if this list was present in the request, false if not. */ @Override protected boolean isPresent(final Request request) { if (isAllowNoSelection()) { String id = getId(); return request.getParameter(id + "-h") != null; } else { return super.isPresent(request); } }
@Test public void testIsPresent() { AbstractInput input = new MyInput(); String testValue = "ABC"; // Empty Request setActiveContext(createUIContext()); MockRequest request = new MockRequest(); Assert.assertFalse("IsPresent should return false", input.isPresent(request)); // Input on the request setActiveContext(createUIContext()); request = new MockRequest(); request.setParameter(input.getId(), testValue); Assert.assertTrue("IsPresent should return true", input.isPresent(request)); }