@Test public final void testFilteringWithoutClean() throws IOException { FacesRequest facesRequest = startFacesRequest(); FacesContext facesContext = FacesContext.getCurrentInstance(); AbstractExtendedDataTable component = (AbstractExtendedDataTable) facesContext.getViewRoot().findComponent("table"); ExtendedDataTableRenderer renderer = (ExtendedDataTableRenderer) FacesContext.getCurrentInstance().getRenderKit() .getRenderer(component.getFamily(), component.getRendererType()); Map<String, Object> column1Attributes = component.findComponent("column1").getAttributes(); Map<String, Object> column2Attributes = component.findComponent("column2").getAttributes(); String clientId = component.getClientId(facesContext); assertNull(column1Attributes.get("filterValue")); assertEquals("filterValue2", column2Attributes.get("filterValue")); facesRequest.withParameter(clientId, clientId); facesRequest.withParameter(clientId + "rich:filtering", "column1:filterValue1:null"); renderer.doDecode(facesContext, component); assertEquals("filterValue1", column1Attributes.get("filterValue")); assertEquals("filterValue2", column2Attributes.get("filterValue")); assertTrue(facesContext.getPartialViewContext().getRenderIds().contains(clientId)); facesRequest.release(); }
@Override protected void doDecode(FacesContext context, final UIComponent component) { super.doDecode(context, component); Map<String, String> map = context.getExternalContext().getRequestParameterMap(); String clientId = component.getClientId(context); updateWidthOfColumns(context, component, map.get(clientId + ":wi")); if (map.get(clientId) != null) { updateColumnsOrder(context, component, map.get("rich:columnsOrder")); } if (map.get(clientId) != null) { updateClientFirst(context, component, map.get("rich:clientFirst")); } decodeSortingFiltering(context, component); if (component.getAttributes().get("tableState") != null) { ExtendedDataTableState tableState = new ExtendedDataTableState((UIDataTableBase) component); updateAttribute(context, component, "tableState", tableState.toString()); } if (component instanceof ClientBehaviorHolder) { final Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors(); if (behaviors == null || behaviors.isEmpty()) { return; } Map<String, String> parametersMap = context.getExternalContext().getRequestParameterMap(); final String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME); if (behaviorEvent == null || !behaviorEvent.startsWith(ROW)) { return; } String behaviorSourceId = RenderKitUtils.getBehaviorSourceId(context); if (behaviorSourceId.endsWith(":n")) { behaviorSourceId = behaviorSourceId.substring(0, behaviorSourceId.length() - 2); } else { return; } ((UIDataAdaptor) component).invokeOnRow(context, behaviorSourceId, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent target) { if (target.equals(component)) { List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent); if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) { for (ClientBehavior behavior : behaviorsForEvent) { behavior.decode(context, component); } } } } }); } }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { @Override protected void doDecode(FacesContext context, final UIComponent component) { super.doDecode(context, component); Map<String, String> map = context.getExternalContext().getRequestParameterMap(); String clientId = component.getClientId(context); updateWidthOfColumns(context, component, map.get(clientId + ":wi")); if (map.get(clientId) != null) { updateColumnsOrder(context, component, map.get("rich:columnsOrder")); } if (map.get(clientId) != null) { updateClientFirst(context, component, map.get("rich:clientFirst")); } decodeSortingFiltering(context, component); if (component.getAttributes().get("tableState") != null) { ExtendedDataTableState tableState = new ExtendedDataTableState((UIDataTableBase) component); updateAttribute(context, component, "tableState", tableState.toString()); } if (component instanceof ClientBehaviorHolder) { final Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors(); if (behaviors == null || behaviors.isEmpty()) { return; } Map<String, String> parametersMap = context.getExternalContext().getRequestParameterMap(); final String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME); if (behaviorEvent == null || !behaviorEvent.startsWith(ROW)) { return; } String behaviorSourceId = RenderKitUtils.getBehaviorSourceId(context); if (behaviorSourceId.endsWith(":n")) { behaviorSourceId = behaviorSourceId.substring(0, behaviorSourceId.length() - 2); } else { return; } ((UIDataAdaptor) component).invokeOnRow(context, behaviorSourceId, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent target) { if (target.equals(component)) { List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent); if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) { for (ClientBehavior behavior : behaviorsForEvent) { behavior.decode(context, component); } } } } }); } } }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { @Override protected void doDecode(FacesContext context, final UIComponent component) { super.doDecode(context, component); Map<String, String> map = context.getExternalContext().getRequestParameterMap(); String clientId = component.getClientId(context); updateWidthOfColumns(context, component, map.get(clientId + ":wi")); if (map.get(clientId) != null) { updateColumnsOrder(context, component, map.get("rich:columnsOrder")); } if (map.get(clientId) != null) { updateClientFirst(context, component, map.get("rich:clientFirst")); } decodeSortingFiltering(context, component); if (component.getAttributes().get("tableState") != null) { ExtendedDataTableState tableState = new ExtendedDataTableState((UIDataTableBase) component); updateAttribute(context, component, "tableState", tableState.toString()); } if (component instanceof ClientBehaviorHolder) { final Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors(); if (behaviors == null || behaviors.isEmpty()) { return; } Map<String, String> parametersMap = context.getExternalContext().getRequestParameterMap(); final String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME); if (behaviorEvent == null || !behaviorEvent.startsWith(ROW)) { return; } String behaviorSourceId = RenderKitUtils.getBehaviorSourceId(context); if (behaviorSourceId.endsWith(":n")) { behaviorSourceId = behaviorSourceId.substring(0, behaviorSourceId.length() - 2); } else { return; } ((UIDataAdaptor) component).invokeOnRow(context, behaviorSourceId, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent target) { if (target.equals(component)) { List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent); if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) { for (ClientBehavior behavior : behaviorsForEvent) { behavior.decode(context, component); } } } } }); } }  }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { @Override protected void doDecode(FacesContext context, final UIComponent component) { super.doDecode(context, component); Map<String, String> map = context.getExternalContext().getRequestParameterMap(); String clientId = component.getClientId(context); updateWidthOfColumns(context, component, map.get(clientId + ":wi")); if (map.get(clientId) != null) { updateColumnsOrder(context, component, map.get("rich:columnsOrder")); } if (map.get(clientId) != null) { updateClientFirst(context, component, map.get("rich:clientFirst")); } decodeSortingFiltering(context, component); if (component.getAttributes().get("tableState") != null) { ExtendedDataTableState tableState = new ExtendedDataTableState((UIDataTableBase) component); updateAttribute(context, component, "tableState", tableState.toString()); } if (component instanceof ClientBehaviorHolder) { final Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors(); if (behaviors == null || behaviors.isEmpty()) { return; } Map<String, String> parametersMap = context.getExternalContext().getRequestParameterMap(); final String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME); if (behaviorEvent == null || !behaviorEvent.startsWith(ROW)) { return; } String behaviorSourceId = RenderKitUtils.getBehaviorSourceId(context); if (behaviorSourceId.endsWith(":n")) { behaviorSourceId = behaviorSourceId.substring(0, behaviorSourceId.length() - 2); } else { return; } ((UIDataAdaptor) component).invokeOnRow(context, behaviorSourceId, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent target) { if (target.equals(component)) { List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent); if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) { for (ClientBehavior behavior : behaviorsForEvent) { behavior.decode(context, component); } } } } }); } }  void encodeHeader(RendererState state); void encodeBody(RendererState state); void encodeFooter(RendererState state); void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId); void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId); RendererState createRowHolder(FacesContext context, UIComponent component, Object[] options); void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder); void consumeTableState(FacesContext facesContext, UIDataTableBase table, ExtendedDataTableState tableState); }
ExtendedDataTableRenderer extends SelectionRenderer implements MetaComponentRenderer { @Override protected void doDecode(FacesContext context, final UIComponent component) { super.doDecode(context, component); Map<String, String> map = context.getExternalContext().getRequestParameterMap(); String clientId = component.getClientId(context); updateWidthOfColumns(context, component, map.get(clientId + ":wi")); if (map.get(clientId) != null) { updateColumnsOrder(context, component, map.get("rich:columnsOrder")); } if (map.get(clientId) != null) { updateClientFirst(context, component, map.get("rich:clientFirst")); } decodeSortingFiltering(context, component); if (component.getAttributes().get("tableState") != null) { ExtendedDataTableState tableState = new ExtendedDataTableState((UIDataTableBase) component); updateAttribute(context, component, "tableState", tableState.toString()); } if (component instanceof ClientBehaviorHolder) { final Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors(); if (behaviors == null || behaviors.isEmpty()) { return; } Map<String, String> parametersMap = context.getExternalContext().getRequestParameterMap(); final String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME); if (behaviorEvent == null || !behaviorEvent.startsWith(ROW)) { return; } String behaviorSourceId = RenderKitUtils.getBehaviorSourceId(context); if (behaviorSourceId.endsWith(":n")) { behaviorSourceId = behaviorSourceId.substring(0, behaviorSourceId.length() - 2); } else { return; } ((UIDataAdaptor) component).invokeOnRow(context, behaviorSourceId, new ContextCallback() { public void invokeContextCallback(FacesContext context, UIComponent target) { if (target.equals(component)) { List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent); if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) { for (ClientBehavior behavior : behaviorsForEvent) { behavior.decode(context, component); } } } } }); } }  void encodeHeader(RendererState state); void encodeBody(RendererState state); void encodeFooter(RendererState state); void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId); void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId); RendererState createRowHolder(FacesContext context, UIComponent component, Object[] options); void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase rowHolder); void consumeTableState(FacesContext facesContext, UIDataTableBase table, ExtendedDataTableState tableState);  }