/** * Handle the reset input action as follows, only and only if the current request is an ajax request and the * {@link PartialViewContext#getRenderIds()} does not return an empty collection nor is the same as * {@link PartialViewContext#getExecuteIds()}: find all {@link EditableValueHolder} components based on * {@link PartialViewContext#getRenderIds()} and if the component is not covered by * {@link PartialViewContext#getExecuteIds()}, then invoke {@link EditableValueHolder#resetValue()} on the * component. * @throws IllegalArgumentException When one of the client IDs resolved to a <code>null</code> component. This * would however indicate a bug in the concrete {@link PartialViewContext} implementation which is been used. */ @Override public void processAction(ActionEvent event) throws AbortProcessingException { FacesContext context = FacesContext.getCurrentInstance(); PartialViewContext partialViewContext = context.getPartialViewContext(); if (partialViewContext.isAjaxRequest()) { Collection<String> renderIds = getRenderIds(partialViewContext); if (!renderIds.isEmpty() && !partialViewContext.getExecuteIds().containsAll(renderIds)) { context.getViewRoot().visitTree(createVisitContext(context, renderIds, VISIT_HINTS), VISIT_CALLBACK); } } if (wrapped != null && event != null) { wrapped.processAction(event); } }
public void resetPickList() { FacesContext facesContext = FacesContext.getCurrentInstance(); UIViewRoot viewRoot = facesContext.getViewRoot(); PartialViewContext partialViewContext = facesContext.getPartialViewContext(); Collection<String> renderIds = partialViewContext.getRenderIds(); for (String renderId : renderIds) { try { UIComponent component = viewRoot.findComponent(renderId); if (component instanceof PickList) { PickList pickList = (PickList) component; pickList.resetValue(); } } catch (Exception e) { logger.error(e); } //logger.info("{0} {1}", new Object[]{renderId, component}); } }
@Override public PartialViewContext getPartialViewContext() { if (_partialViewContext == null) { PartialViewContextFactory f = (PartialViewContextFactory) FactoryFinder.getFactory(FactoryFinder.PARTIAL_VIEW_CONTEXT_FACTORY); _partialViewContext = f.getPartialViewContext(this); } return _partialViewContext; }
/** * Helper method with RichFaces4 hack to return the proper render IDs from the given partial view context. * @param partialViewContext The partial view context to return the render IDs for. * @return The render IDs. */ private static Collection<String> getRenderIds(PartialViewContext partialViewContext) { Collection<String> renderIds = partialViewContext.getRenderIds(); // WARNING: START OF HACK! ------------------------------------------------------------------------------------ // HACK for RichFaces4 because its ExtendedPartialViewContextImpl class doesn't return its componentRenderIds // property on getRenderIds() call when the action is executed using a RichFaces-specific command button/link. // See also https://issues.jboss.org/browse/RF-11112 //if (renderIds.isEmpty() && Hacks.isRichFacesInstalled()) { // renderIds = Hacks.getRichFacesRenderIds(); //} // END OF HACK ------------------------------------------------------------------------------------------------ return renderIds; }
public PartialViewContext getPartialViewContext() { return _mockPartialContext; }
private boolean isAjaxRequest() { PartialViewContext partialViewContext = FacesContext.getCurrentInstance().getPartialViewContext(); return null != partialViewContext && partialViewContext.isAjaxRequest(); }
public PartialViewContext getPartialViewContext(FacesContext context) { return new TFPartialViewContext(wrapped.getPartialViewContext(context)); }
public TFPartialViewContext(PartialViewContext wrapped) { this.wrapped = wrapped; this.writer = new TFPartialResponseWriter(wrapped.getPartialResponseWriter()); }
public PartialViewContext getWrapped() { return wrapped; }
protected boolean isAjaxRequest() { PartialViewContext partialViewContext = FacesContext.getCurrentInstance().getPartialViewContext(); return partialViewContext != null && partialViewContext.isAjaxRequest(); }
@Override public PartialViewContext getPartialViewContext() { return FacesContextUtil.getFacesContext().getPartialViewContext(); }
public static void addPartialViewRender(String id) { PartialViewContext pcontext = FacesContext.getCurrentInstance().getPartialViewContext(); if (pcontext != null) { pcontext.getRenderIds().add(id); } }
/** * Creates a PartialViewContext instance that is optimized for Trinidad PPR. * @param context * @return a PartialViewContext instance */ public PartialViewContext getPartialViewContext(FacesContext context) { return new PartialViewContextImpl(context); }