public static String readPersonId() { String personId = null; try { FacesContext context = FacesContext.getCurrentInstance(); IWContext iwContext = IWContext.getIWContext(context); personId = iwContext.getCurrentUser().getPersonalID(); } catch (Throwable ex) { log.warn("Unable to read Personal Id from IWContext", ex); } return personId == null ? EhealthConstants.DEFAULT_PERSON_ID : personId; }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { if (iwma == null) { iwma = IWMainApplication.getIWMainApplication(servletConfig.getServletContext()); } if (request.getParameter(PARAMETER_NAME) != null || request.getParameter("image_id") != null) { new MediaOutputWriter().doPost(request, response, iwma); } else if (request.getParameter(PRM_SESSION_MEMORY_BUFFER) != null) { new MemoryFileBufferWriter().doPost(request, response); } else if (request.getParameter(MediaWritable.PRM_WRITABLE_CLASS) != null) { IWContext iwc = null; try { FacesContext facesContext = facesContextFactory.getFacesContext( servletConfig.getServletContext(), request, response, lifecycle); iwc = IWContext.getIWContext(facesContext); } catch (Exception e) { e.printStackTrace(); } try { if (iwc == null) { iwc = new IWContext(request, response, servletConfig.getServletContext()); } String mediaWriter = request.getParameter(MediaWritable.PRM_WRITABLE_CLASS); MediaWritable mw = (MediaWritable) RefactorClassRegistry.forName(IWMainApplication.decryptClassName(mediaWriter)) .newInstance(); mw.init(request, iwc); response.setContentType(mw.getMimeType()); ServletOutputStream out = response.getOutputStream(); mw.writeTo(out); out.flush(); } catch (Exception ex) { ex.printStackTrace(); } } }
@Override protected void initializeComponent(FacesContext context) { super.initializeComponent(context); IWContext iwc = IWContext.getIWContext(context); IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); IWResourceBundle iwrb = bundle.getResourceBundle(iwc); Layer container = new Layer(); add(container); PublicEventCreator creator = new PublicEventCreator(); creator.setOnEventCreated( "function() {window.parent.showLoadingMessage('" .concat(iwrb.getLocalizedString("reloading", "Reloading...")) .concat("');window.parent.reloadPage();}")); container.add(creator); Layer events = new Layer(); container.add(events); IFrame frame = new IFrame("eventsViewer", "http://bedework.sidan.is/cal/main/showMain.rdo", 750, 600); events.add(frame); // IWContext iwc = IWContext.getIWContext(context); // if (!iwc.isLoggedOn()) { // return; // } // // HtmlTag div = // (HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE); // div.setValue(divTag); // div.setStyleClass("calendarEventCreator"); // // IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); // IWResourceBundle iwrb = bundle.getResourceBundle(iwc); // // GenericButton gb = new GenericButton(); // div.getChildren().add(gb); // gb.setValue(iwrb.getLocalizedString("show_event", "Show event")); // // PresentationUtil.addStyleSheetToHeader(iwc, // web2Business.getBundleURIToFancyBoxStyleFile()); // // List<String> jsFiles = new ArrayList<String>(); // jsFiles.add(jQuery.getBundleURIToJQueryLib()); // jsFiles.addAll(web2Business.getBundleURIsToFancyBoxScriptFiles()); // // jsFiles.add(bundle.getVirtualPathWithFileNameString("javascript/EventCreationHelper.js")); // PresentationUtil.addJavaScriptSourcesLinesToHeader(iwc, jsFiles); // String action = "EventCreationHelper.initializeHiddenLink();"; // if (!CoreUtil.isSingleComponentRenderingProcess(iwc)) { // action = "jQuery(window).load(function() {" + action + "});"; // } // // PresentationUtil.addJavaScriptActionToBody(iwc, action); // gb.setOnClick("EventCreationHelper.showPublicEventsWindow();"); // // getChildren().add(div); // HtmlTag div = // (HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE); // div.setValue(divTag); // // IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); // FaceletComponent facelet = // (FaceletComponent)context.getApplication().createComponent(FaceletComponent.COMPONENT_TYPE); // facelet.setFaceletURI(bundle.getFaceletURI("EventViewer.xhtml")); // // div.getChildren().add(facelet); // getChildren().add(div); }
@Override protected void updateComponent(FacesContext context) { this.getChildren().clear(); add(getEditContainer(IWContext.getIWContext(context), true)); }
@Override protected void initializeComponent(FacesContext context) { add(getEditContainer(IWContext.getIWContext(context), false)); }
@SuppressWarnings("unchecked") @Override protected void initializeComponent(FacesContext context) { ELUtil.getInstance().autowire(this); iwc = IWContext.getIWContext(context); if (!iwc.isLoggedOn()) { return; } if (userId == null) { userId = iwc.getCurrentUserId(); } // HtmlTag div = new // HtmlTag();//(HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE); // getChildren().add(div); // div.setValue(divTag); Layer main = new Layer(); this.add(main); IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER); iwrb = bundle.getResourceBundle(iwc); if (groupId == null) { Label label = new Label(); main.add(label); label.addText(iwrb.getLocalizedString("no_group_set", "No group set")); return; } Group group = null; Collection<Group> groups = null; try { group = this.getUserBusiness().getGroupBusiness().getGroupByGroupID(Integer.valueOf(groupId)); groups = this.getUserBusiness().getUserGroups(userId); } catch (Exception e) { Logger.getLogger(this.getClass().getName()) .log(Level.WARNING, "failed getting groups by ids", e); } GenericButton joinButton = new GenericButton(); main.add(joinButton); GenericButton leaveButton = new GenericButton(); main.add(leaveButton); StringBuilder parameters = new StringBuilder() .append(this.userId) .append(CoreConstants.JS_STR_PARAM_SEPARATOR) .append(this.groupId) .append("','#") .append(joinButton.getId()) .append("','#") .append(leaveButton.getId()) .append(CoreConstants.JS_STR_PARAM_END); joinButton.setValue(iwrb.getLocalizedString("join", "Join")); String action = new StringBuilder("GroupJoinerHelper.joinGroup('").append(parameters).toString(); joinButton.setOnClick(action); leaveButton.setValue(iwrb.getLocalizedString("leave", "Leave")); action = new StringBuilder("GroupJoinerHelper.leaveGroup('").append(parameters).toString(); leaveButton.setOnClick(action); if (groups.contains(group)) { joinButton.setStyleAttribute("display : none;"); } else { leaveButton.setStyleAttribute("display : none;"); } addActions(main); }