Java Code Examples for javax.faces.context.FacesContext#getViewRoot()
The following examples show how to use
javax.faces.context.FacesContext#getViewRoot() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StateManagerTestImpl.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
@Override public UIViewRoot restoreView(FacesContext context, String viewId, String renderKitId) { SerializedView serView = restore(); Node node = (Node) serView.getStructure(); try { UIViewRoot root = (UIViewRoot) node.restore(ClassLoaderUtil.getContextClassLoader(StateManagerTestImpl.class)); FacesUtil.setRestoreRoot(context, root); UIViewRoot old = context.getViewRoot(); try { context.setViewRoot(root); root.processRestoreState(context, serView.getState()); } finally { context.setViewRoot(old); } FacesUtil.setRestoreRoot(context, null); return root; } catch(Exception e) { throw new FacesExceptionEx(e); } }
Example 2
Source File: UIDojoContentPane.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
public String getAjaxUrl(FacesContext context) { UIViewRootEx root = (UIViewRootEx)context.getViewRoot(); // Compute a partial refresh URL... StringBuilder b = new StringBuilder(); String actionURL = context.getApplication().getViewHandler().getActionURL(context, root.getViewId()); b.append(actionURL); b.append("?$$ajaxid="); // $NON-NLS-1$ b.append(getClientId(context)); b.append("&$$ajaxinner=content"); // $NON-NLS-1$ String uniqueId = root.getUniqueViewId(); if(StringUtil.isNotEmpty(uniqueId)) { b.append("&$$viewid="); // $NON-NLS-1$ b.append(uniqueId); } return b.toString(); }
Example 3
Source File: OneUIMenuRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
@Override protected void preRenderTree(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException { // Add the JS support if necessary if(isExpandable()) { UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot(); rootEx.setDojoTheme(true); ExtLibResources.addEncodeResource(rootEx, OneUIResources.oneUINavigator); // Specific dojo effects String effect = getExpandEffect(); if(StringUtil.isNotEmpty(effect)) { rootEx.addEncodeResource(ExtLibResources.dojoFx); ExtLibResources.addEncodeResource(rootEx, ExtLibResources.dojoFx); } } super.preRenderTree(context, writer, tree); }
Example 4
Source File: DialogRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public void encodeBeginOriginal(FacesContext context, UIComponent component) throws IOException { ResponseWriter w = context.getResponseWriter(); UIDialog dialog = (UIDialog)component; String clientId = dialog.getClientId(context); // Add the dojo module UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); ExtLibResources.addEncodeResource(rootEx, getDefaultDojoModule(context,dialog)); rootEx.setDojoParseOnLoad(true); rootEx.setDojoTheme(true); // Main dialog div w.startElement("span", component); // $NON-NLS-1$ w.writeAttribute("id", clientId, "id"); // $NON-NLS-1$ $NON-NLS-2$ // The dialog should be hidden by default // Else, the tooltip dialog will be popep-up twice, thus sending the // onShow events twice... w.writeAttribute("style", ExtLibUtil.concatStyles("display: none",dialog.getStyle()), "style"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$ // Compose the list of attributes from the list of dojo attributes // Note that we ignore the dojoType as we don't want the tag to be parsed. // -> we only write the attributes Map<String,String> attrs = DojoRendererUtil.createMap(context); DojoRendererUtil.getDojoAttributeMap(dialog,attrs); initDojoAttributes(context, dialog, attrs); DojoUtil.writeDojoHtmlAttributesMap(context,attrs); }
Example 5
Source File: ConfigManager.java From netbeans with Apache License 2.0 | 5 votes |
/** * Publishes a {@link javax.faces.event.PostConstructApplicationEvent} event for the current * {@link Application} instance. */ void publishPostConfigEvent() { FacesContext ctx = FacesContext.getCurrentInstance(); Application app = ctx.getApplication(); if (null == ((InitFacesContext)ctx).getELContext()) { ELContext elContext = new ELContextImpl(app.getELResolver()); elContext.putContext(FacesContext.class, ctx); UIViewRoot root = ctx.getViewRoot(); if (null != root) { elContext.setLocale(root.getLocale()); } ELContextListener[] listeners = app.getELContextListeners(); if (listeners.length > 0) { ELContextEvent event = new ELContextEvent(elContext); for (ELContextListener listener: listeners) { listener.contextCreated(event); } } ((InitFacesContext)ctx).setELContext(elContext); } app.publishEvent(ctx, PostConstructApplicationEvent.class, Application.class, app); }
Example 6
Source File: DynamicControlRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { super.encodeBegin(context, component); ResponseWriter w = context.getResponseWriter(); String clientId = component.getClientId(context); w.startElement("div", component); // $NON-NLS-1$ w.writeAttribute("id", clientId, "id"); // $NON-NLS-1$ $NON-NLS-2$ //w.writeAttribute("style", "display: none", "style"); // Add the newly added resources, if some if(AbstractDynamicContent.USE_DYNAMIC_RESOURCES) { Integer rc = (Integer)context.getExternalContext().getRequestMap().get(AbstractDynamicContent.DYNAMIC_RESOURCES); if(rc!=null) { UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); List<Resource> resources = rootEx.getResources(); int count = resources.size(); boolean isTraceDebug = ExtlibControlsLogger.CONTROLS.isTraceDebugEnabled(); for(int i=rc; i<count; i++) { Resource resource = resources.get(i); if( isTraceDebug ){ ExtlibControlsLogger.CONTROLS.traceDebugp(this, "encodeBegin", //$NON-NLS-1$ StringUtil.format("Added a dynamic resource, {0}", resource.getClass().getName())); //$NON-NLS-1$ } rootEx.addEncodeResource(resource); } } } }
Example 7
Source File: DojoFormWidgetRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected String writeDojoAttributes(FacesContext context, FacesDojoComponent dojoComponent) throws IOException { UIViewRootEx viewEx = (UIViewRootEx)context.getViewRoot(); String dojoType = dojoComponent.getDojoType(); if(StringUtil.isEmpty(dojoType)) { dojoType = getDefaultDojoType(context, dojoComponent); // If the resources for the dojo type haven't been emitted yet, then do it // Not that the XPages runtime ensures that the resources are not emitted multiple times // This is simply an optimization if(shouldWriteModule(context, viewEx, dojoComponent, dojoType)) { writeDefaultDojoModule(context, viewEx, dojoComponent, dojoType); } } else { if(shouldWriteModule(context, viewEx, dojoComponent, dojoType)) { writeDojoModule(context, viewEx, dojoComponent, dojoType); } } Map<String,String> attrs = DojoRendererUtil.createMap(context); // Compose the list of attributes from the list of dojo attributes DojoRendererUtil.getDojoAttributeMap(dojoComponent,attrs); // Add the attributes specific to this control initDojoAttributes(context, dojoComponent, attrs); // And generate them DojoRendererUtil.writeDojoHtmlAttributes(context,(UIComponent)dojoComponent,dojoType,attrs); return dojoType; }
Example 8
Source File: UIDojoFormWidgetBase.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void initAfterContents(FacesContext context) throws FacesException { super.initAfterContents(context); // ensure that the form has the right dojo type UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); if(rootEx!=null) { UIFormEx formEx = (UIFormEx)FacesUtil.getForm(this); String formType = formEx.getDojoType(); if(StringUtil.isEmpty(formType)) { rootEx.setDojoForm(true); //formEx.setDojoType("dijit.form.Form"); rootEx.addResource(ExtLibResources.dijitFormForm); } } }
Example 9
Source File: DojoAccordionRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override protected void preRenderTree(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException { AbstractOutline outline = (AbstractOutline)tree.getComponent(); UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot(); rootEx.setDojoTheme(true); rootEx.setDojoParseOnLoad(true); writer.startElement("div", null); // $NON-NLS-1$ String id = getClientId(); if(StringUtil.isNotEmpty(id)) { writer.writeAttribute("id",id,null); // $NON-NLS-1$ } String dojoType = outline.getDojoType(); if(StringUtil.isEmpty(dojoType)) { dojoType = "dijit.layout.AccordionContainer"; // $NON-NLS-1$ ExtLibResources.addEncodeResource(rootEx, ExtLibResources.dijitLayoutAccordion); } String style = outline.getStyle(); if(StringUtil.isNotEmpty(style)) { writer.writeAttribute("style",style,null); // $NON-NLS-1$ } String styleClass = outline.getStyleClass(); if(StringUtil.isNotEmpty(styleClass)) { writer.writeAttribute("class",styleClass,null); // $NON-NLS-1$ } Map<String,String> attrs = DojoRendererUtil.createMap(context); DojoRendererUtil.getDojoAttributeMap(outline,attrs); initDojoAttributes(context, outline, attrs); DojoUtil.addDojoHtmlAttributes(context,dojoType,null,attrs); writer.write('\n'); }
Example 10
Source File: DataViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { // Encode the necessary resource UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); ExtLibResources.addEncodeResource(rootEx, Resources.bootstrapCheckbox); ExtLibResources.addEncodeResource(rootEx, ExtLibResources.extlibExtLib); super.encodeBegin(context, component); }
Example 11
Source File: OneUIv302MenuRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override protected void preRenderTree(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException { if(isExpandable()) { UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot(); rootEx.setDojoTheme(true); ExtLibResources.addEncodeResource(rootEx, OneUIResources.oneUINavigator); // Specific dojo effects String effect = getExpandEffect(); if(StringUtil.isNotEmpty(effect)) { rootEx.addEncodeResource(ExtLibResources.dojoFx); ExtLibResources.addEncodeResource(rootEx, ExtLibResources.dojoFx); } } writer.startElement("div", null); // $NON-NLS-1$ writer.writeAttribute("class", (String)getProperty(PROP_MENU_MENU),null); // $NON-NLS-1$ writer.writeAttribute("role", "navigation",null); // $NON-NLS-1$ $NON-NLS-2$ writer.writeAttribute("aria-label", "Menu navigation", null); // $NON-NLS-1$ // $NLS-OneUIv302MenuRenderer_NavAriaLabel_MenuNavigation-2$ writeClientIdIfNecessary(context, writer, tree); writer.startElement("div", null); // $NON-NLS-1$ writer.writeAttribute("class", (String)getProperty(PROP_MENU_BOTTOMCORNER),null); // $NON-NLS-1$ writer.startElement("div", null); // $NON-NLS-1$ writer.writeAttribute("class", (String)getProperty(PROP_MENU_INNER),null); // $NON-NLS-1$ $NON-NLS-2$ writer.startElement("div", null); // $NON-NLS-1$ writer.writeAttribute("class", (String)getProperty(PROP_MENU_HEADER), null);//$NON-NLS-1$ writer.writeAttribute("role", "tree", null); // $NON-NLS-1$ // $NON-NLS-2$ }
Example 12
Source File: DojoWidgetBaseRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
protected String writeDojoAttributes(FacesContext context, FacesDojoComponent dojoComponent) throws IOException { UIViewRootEx viewEx = (UIViewRootEx)context.getViewRoot(); String dojoType = dojoComponent.getDojoType(); if (StringUtil.isEmpty(dojoType)) { dojoType = getDefaultDojoType(context, dojoComponent); // If the resources for the dojo type haven't been emitted yet, then do it // Not that the XPages runtime ensures that the resources are not emitted multiple times // This is simply an optimization if(shouldWriteModule(context, viewEx, dojoComponent, dojoType)) { writeDefaultDojoModule(context, viewEx, dojoComponent, dojoType); } } else { if(shouldWriteModule(context, viewEx, dojoComponent, dojoType)) { writeDojoModule(context, viewEx, dojoComponent, dojoType); } } if (StringUtil.isNotEmpty(dojoType)) { Map<String, String> attrs = DojoRendererUtil.createMap(context); // Compose the list of attributes from the list of dojo attributes DojoRendererUtil.getDojoAttributeMap(dojoComponent, attrs); // Add the attributes specific to this control initDojoAttributes(context, dojoComponent, attrs); // And generate them DojoRendererUtil.writeDojoHtmlAttributes(context, (UIComponent) dojoComponent, dojoType, attrs); } return dojoType; }
Example 13
Source File: ForumViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { // Encode the necessary resource UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); ExtLibResources.addEncodeResource(rootEx, ExtLibResources.extlibExtLib); super.encodeBegin(context, component); }
Example 14
Source File: DeltaSpikeLifecycleWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
/** * Performs cleanup tasks after the rendering process */ @Override public void render(FacesContext facesContext) { this.wrapped.render(facesContext); if (facesContext.getViewRoot() != null && facesContext.getViewRoot().getViewId() != null) { ViewAccessContext viewAccessContext = contextExtension.getViewAccessScopedContext(); if (viewAccessContext != null) { viewAccessContext.onProcessingViewFinished(facesContext.getViewRoot().getViewId()); } } }
Example 15
Source File: NotesListViewDesignRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter w = context.getResponseWriter(); UINotesListViewDesign uiComponent = (UINotesListViewDesign) component; boolean rendered = component.isRendered(); if (!rendered) return; UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot(); rootEx.addEncodeResource(DojoResources.dominoDesignStore); rootEx.setDojoParseOnLoad(true); String url = getDbUrl(context, uiComponent); w.startElement("span", null); // $NON-NLS-1$ w.writeAttribute(DojoResourceConstants.dojoType, DojoResourceConstants.DominoReadDesign, null); String id = uiComponent.getClientId(context); if (StringUtil.isNotEmpty(id)) w.writeAttribute("id", id, null); // $NON-NLS-1$ String jsId = uiComponent.getDojoWidgetJsId(context); if (StringUtil.isNotEmpty(jsId)) w.writeAttribute("jsId", jsId, null); // $NON-NLS-1$ w.writeAttribute("url", url, null); // $NON-NLS-1$ w.writeAttribute("dwa", "false", null); // $NON-NLS-1$ $NON-NLS-2$ }
Example 16
Source File: CalendarViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter w = context.getResponseWriter(); UICalendarView uiComponent = (UICalendarView) component; boolean rendered = component.isRendered(); if (!rendered) return; UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot(); rootEx.addEncodeResource(DojoResources.calendarView); rootEx.addEncodeResource(DojoResources.calendarViewCSS); rootEx.addEncodeResource(DojoResources.datepickCSS); rootEx.setDojoParseOnLoad(true); rootEx.setDojoTheme(true); //TODO may need to support multiple store. String store = ExtlibJsIdUtil.findDojoWidgetId(context, uiComponent, uiComponent.getStoreComponentId()); w.startElement("div", uiComponent); // $NON-NLS-1$ if(StringUtil.isNotEmpty(store)) w.writeAttribute("store", store, null); // $NON-NLS-1$ String style = uiComponent.getStyle(); if (StringUtil.isNotEmpty(style)) w.writeAttribute("style", style, null); // $NON-NLS-1$ String classname = uiComponent.getStyleClass(); if (StringUtil.isNotEmpty(classname)) w.writeAttribute("class", classname, null); // $NON-NLS-1$ // Always write the id since Dojo-based controls need an ID. w.writeAttribute("id", uiComponent.getClientId(context), null); // $NON-NLS-1$ String jsId = uiComponent.getDojoWidgetJsId(context); if (StringUtil.isNotEmpty(jsId)) w.writeAttribute("jsId", jsId, null); // $NON-NLS-1$ String type = uiComponent.getType(); w.writeAttribute(DojoResourceConstants.dojoType, DojoResourceConstants.calendarView, null); if (StringUtil.isNotEmpty(type)) w.writeAttribute("type", type, null); // $NON-NLS-1$ w.writeAttribute("summarize", uiComponent.isSummarize(), // $NON-NLS-1$ null); w.writeAttribute("tabindex", "0", null); // $NON-NLS-1$ w.writeAttribute("role", "grid", null); // $NON-NLS-1$ //$NON-NLS-2$ w.writeAttribute("aria-label", "Calendar View", null); // $NON-NLS-1$ $NLS-CalendarViewRenderer.CalendarView-2$ Date date = uiComponent.getDate(); if (null != date){ Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.setTimeZone(TimeZone.getTimeZone("UTC")); // $NON-NLS-1$ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd'T'HH:mm:ssZ"); // $NON-NLS-1$ String datetext = sdf.format(cal.getTime()); w.writeAttribute("date", datetext, null); // $NON-NLS-1$ } //MNAA9UBBLH boolean disableDragNDropCalendar = "true".equals( //$NON-NLS-1$ FacesContextEx.getCurrentInstance().getApplicationEx() .getProperty(XSP_DISABLE_DRAGNDROP_CALENDAR, "false")); //$NON-NLS-1$ if(disableDragNDropCalendar) w.writeAttribute("nCalViewDragDrop", "0", null); // $NON-NLS-1$ //MNAA9VSHWR boolean disableInLineEditCalendar = "true".equals( //$NON-NLS-1$ FacesContextEx.getCurrentInstance().getApplicationEx() .getProperty(XSP_DISABLE_INLINE_EDIT_CALENDAR, "false")); //$NON-NLS-1$ if(disableInLineEditCalendar) w.writeAttribute("fDisableInPlaceEdit", "true", null); // $NON-NLS-1$ //$NON-NLS-2$ uiComponent.writeActionHandlerScripts(w); }
Example 17
Source File: SimpleResponsiveLayoutRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
protected void writeMainFrame(FacesContext context, ResponseWriter w, UIApplicationLayout c, SimpleResponsiveApplicationConfiguration configuration) throws IOException { boolean isNavbar = false; boolean invertedNavbar = false; String fixedNavbar = ""; boolean collapseLeftColumn = false; String collapseLeftTarget = ""; String collapsedLeftMenuLabel = ""; String pageWidthClass = ""; if(configuration!=null) { isNavbar = configuration.isNavbar(); invertedNavbar = configuration.isInvertedNavbar(); collapseLeftColumn = configuration.isCollapseLeftColumn(); String target = configuration.getCollapseLeftTarget(); collapseLeftTarget = (StringUtil.isNotEmpty(target) ? target : (String)getProperty(COLLAPSE_LEFT_COLUMN_TARGET)); String menuLabel = configuration.getCollapsedLeftMenuLabel(); collapsedLeftMenuLabel = (StringUtil.isNotEmpty(menuLabel) ? menuLabel : (String)getProperty(COLLAPSE_LEFT_MENU_LABEL)); pageWidthClass = getContainerClass(configuration); String fixed = configuration.getFixedNavbar(); fixedNavbar = (StringUtil.isNotEmpty(fixed) ? fixed : SimpleResponsiveApplicationConfiguration.NAVBAR_FIXED_TOP); } UIViewRoot viewRoot = context.getViewRoot(); String renderKitId = ""; if( null != viewRoot ){ renderKitId = viewRoot.getRenderKitId(); } w.writeComment("renderKitId: " + renderKitId); // $NON-NLS-1$ newLine(w); //CSS required for fixed Banner if (isNavbar && !StringUtil.isEmpty(fixedNavbar)) { String navbarPadding = ""; boolean addStyle = false; if(fixedNavbar.equals(ResponsiveApplicationConfiguration.NAVBAR_FIXED_TOP)) { navbarPadding = (String)getProperty(PROP_BANNER_FIXEDTOP_PADDING); addStyle = true; }else if(fixedNavbar.equals(ResponsiveApplicationConfiguration.NAVBAR_FIXED_BOTTOM)) { navbarPadding = (String)getProperty(PROP_BANNER_FIXEDBOTTOM_PADDING); addStyle = true; } if(addStyle) { w.startElement("style", c); // $NON-NLS-1$ w.writeAttribute("type", "text/css", null); // $NON-NLS-1$ $NON-NLS-2$ w.writeText(navbarPadding, null); w.endElement("style"); // $NON-NLS-1$ } } w.startElement("div", c); // $NON-NLS-1$ w.writeAttribute("class", "applayout-main", null); // $NON-NLS-1$ $NON-NLS-2$ if (HtmlUtil.isUserId(c.getId())) { w.writeAttribute("id", c.getClientId(context), null); // $NON-NLS-1$ } if (configuration != null) { // Start the navbar if (isNavbar) { writeNavbar(context, w, c, configuration, invertedNavbar, fixedNavbar, pageWidthClass); } // Start the main content writeMainContent(context, w, c, configuration, collapseLeftColumn, pageWidthClass, collapseLeftTarget, collapsedLeftMenuLabel); } // Close the main frame w.endElement("div"); // $NON-NLS-1$ newLine(w); }
Example 18
Source File: MobilePageRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { super.encodeBegin(context, component); ResponseWriter w = context.getResponseWriter(); UIMobilePage page = (UIMobilePage)component; UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); rootEx.setDojoParseOnLoad(true); rootEx.setDojoTheme(true); String clientId = component.getClientId(context); w.startElement("div", component); // $NON-NLS-1$ // Setting a page name overrides the clientId. Therefore the user will need to make // sure that it's unique across the single application. Dojox.mobile requires us // to use HTML ids meaning that normally the JSF client ids may appear in the URL, // depending on the application this may be sub optimal, requiring this override. String pageName = page.getPageName(); if(pageName != null){ w.writeAttribute("pageName", pageName, "pageName"); // $NON-NLS-1$ $NON-NLS-2$ w.writeAttribute("id", pageName, "id"); // $NON-NLS-1$ $NON-NLS-2$ } else{ w.writeAttribute("pageName", clientId, "pageName"); // $NON-NLS-1$ $NON-NLS-2$ w.writeAttribute("id", clientId, "id"); // $NON-NLS-1$ $NON-NLS-2$ } String dojoType = getDojoType(); if(StringUtil.isEmpty(dojoType)) { throw new IllegalStateException(); } w.writeAttribute("dojoType", dojoType, "dojoType"); // $NON-NLS-1$ $NON-NLS-2$ DojoModuleResource module = getDojoModule(); if(module!=null) { ExtLibResources.addEncodeResource(rootEx, module); } boolean keepScrollPos = page.isKeepScrollPos(); if(keepScrollPos != true/*defaults to true*/) { w.writeAttribute("keepScrollPos", "false", "keepScrollPos"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$ } boolean resetContent = page.isResetContent(); if(resetContent) { w.writeAttribute("resetContent", resetContent, "resetContent"); // $NON-NLS-1$ $NON-NLS-2$ } boolean preload = page.isPreload(); if ( preload ) { w.writeAttribute("preload", preload, "preload"); // $NON-NLS-1$ $NON-NLS-2$ } //TODO: should this be changed/removed/merged with preload? boolean loaded = preload; //loaded is not editable by the user if ( loaded ) { w.writeAttribute("loaded", loaded, "loaded"); // $NON-NLS-1$ $NON-NLS-2$ } String onBeforeTransitionIn = page.getOnBeforeTransitionIn(); if( null != onBeforeTransitionIn ){ w.writeAttribute("onBeforeTransitionIn", onBeforeTransitionIn, "onBeforeTransitionIn"); //$NON-NLS-1$ //$NON-NLS-2$ } String onAfterTransitionIn = page.getOnAfterTransitionIn(); if( null != onAfterTransitionIn ){ w.writeAttribute("onAfterTransitionIn", onAfterTransitionIn, "onAfterTransitionIn"); //$NON-NLS-1$ //$NON-NLS-2$ } String onBeforeTransitionOut = page.getOnBeforeTransitionOut(); if( null != onBeforeTransitionOut ){ w.writeAttribute("onBeforeTransitionOut", onBeforeTransitionOut, "onBeforeTransitionOut"); //$NON-NLS-1$ //$NON-NLS-2$ } String onAfterTransitionOut = page.getOnAfterTransitionOut(); if( null != onAfterTransitionOut ){ w.writeAttribute("onAfterTransitionOut", onAfterTransitionOut, "onAfterTransitionOut"); //$NON-NLS-1$ //$NON-NLS-2$ } AttrsUtil.encodeAttrs(context, w, page); JSUtil.writeln(w); }
Example 19
Source File: ExtLibResources.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public static void addEncodeResource(FacesContext context, Resource resource) { UIViewRootEx rootEx = (UIViewRootEx)context.getViewRoot(); addEncodeResource(rootEx,resource); }
Example 20
Source File: ListViewRenderer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { ResponseWriter w = context.getResponseWriter(); UIListView uiComponent = (UIListView) component; boolean rendered = component.isRendered(); if (!rendered) return; UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot(); rootEx.addEncodeResource(DojoResources.notesFullListView); rootEx.addEncodeResource(DojoResources.listViewCSS); rootEx.setDojoParseOnLoad(true); rootEx.setDojoTheme(true); String store = ExtlibJsIdUtil.findDojoWidgetId(context, uiComponent, uiComponent.getStoreComponentId()); String structure = ExtlibJsIdUtil.findDojoWidgetId(context, uiComponent, uiComponent.getStructureComponentId()); String id = uiComponent.getClientId(context); String jsId = uiComponent.getDojoWidgetJsId(context); if(StringUtil.isEmpty(structure) && component.getChildCount() == 0){//need to be revised// rootEx.addEncodeResource(DojoResources.dominoDesignStore); w.startElement("span", null); // $NON-NLS-1$ w.writeAttribute(DojoResourceConstants.dojoType, DojoResourceConstants.DominoReadDesign, null); structure = uiComponent.getDojoWidgetJsId(context) + "_default_view_design_jsid"; // $NON-NLS-1$ w.writeAttribute("jsId", structure , null); // $NON-NLS-1$ w.writeAttribute("dwa", "false", null); // $NON-NLS-1$ $NON-NLS-2$ w.endElement("span"); // $NON-NLS-1$ } w.startElement("div", uiComponent); // $NON-NLS-1$ String style = uiComponent.getStyle(); if (StringUtil.isNotEmpty(style)) w.writeAttribute("style", style, null); // $NON-NLS-1$ String classname = uiComponent.getStyleClass(); if (StringUtil.isNotEmpty(classname)) w.writeAttribute("class", classname, null); // $NON-NLS-1$ w.writeAttribute(DojoResourceConstants.dojoType, DojoResourceConstants.notesFullListView, null); if(StringUtil.isNotEmpty(store)) w.writeAttribute("store", store, null); // $NON-NLS-1$ if(StringUtil.isNotEmpty(structure)) w.writeAttribute("structure", structure, null); // $NON-NLS-1$ if (StringUtil.isNotEmpty(id)) w.writeAttribute("id", id, null); // $NON-NLS-1$ if (StringUtil.isNotEmpty(jsId)) w.writeAttribute("jsId", jsId, null); // $NON-NLS-1$ if(uiComponent.isHideColumns()){ // the internal attr tag can remain 'hideColumn' w.writeAttribute("hideColumn", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } if(uiComponent.isAlternateRows()){ w.writeAttribute("alternateRows", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } if(uiComponent.isCanBeNarrowMode()){ w.writeAttribute("canBeNarrowMode", "true", null); // $NON-NLS-1$ $NON-NLS-2$ } String hookedEvents = ""; if( StringUtil.isNotEmpty(uiComponent.getOnCellClick()) ){ hookedEvents = "click"; // $NON-NLS-1$ } if( StringUtil.isNotEmpty(uiComponent.getOnCellDblClick()) ){ if( hookedEvents.length() > 0 ){ hookedEvents += ",dblclick"; // $NON-NLS-1$ }else{ hookedEvents = "dblclick"; // $NON-NLS-1$ } } if( hookedEvents.length() > 0 ){ w.writeAttribute("hookedEvents", hookedEvents, null); // $NON-NLS-1$ } }