protected String getSaveAndContinueRedirect( ActionRequest actionRequest, TaskRecord taskRecord, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editTaskRecord"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(taskRecord.getGroupId()), false); portletURL.setParameter( "taskRecordId", String.valueOf(taskRecord.getTaskRecordId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Contact contact, Layout layout, String redirect) throws Exception { _log.info("getSaveAndContinueRedirect()"); PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editContact"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(contact.getGroupId()), false); portletURL.setParameter( "contactId", String.valueOf(contact.getContactId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Measurement measurement, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editMeasurement"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(measurement.getGroupId()), false); portletURL.setParameter( "measurementId", String.valueOf(measurement.getMeasurementId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override public boolean especificValidations(UploadRequest uploadRequest, PortletResponse portletResponse) { PortletRequest actionRequest = (PortletRequest)uploadRequest.getAttribute( JavaConstants.JAVAX_PORTLET_REQUEST); boolean validate=true; if((Validator.isNotNull(uploadRequest.getParameter("random")))&& ((!Validator.isNumber(uploadRequest.getParameter("random")))|| (Long.parseLong(uploadRequest.getParameter("random"))>100)|| (Long.parseLong(uploadRequest.getParameter("random"))<0))) { SessionErrors.add(actionRequest, "execactivity.editActivity.random.number"); validate=false; } if((Validator.isNotNull(uploadRequest.getParameter("questionsPerPage")))&& ((!Validator.isNumber(uploadRequest.getParameter("questionsPerPage")))|| (Long.parseLong(uploadRequest.getParameter("questionsPerPage"))>100)|| (Long.parseLong(uploadRequest.getParameter("questionsPerPage"))<0))) { SessionErrors.add(actionRequest, "execactivity.editActivity.questionsPerPage.number"); validate=false; } return validate; }
@Override public boolean especificValidations(UploadRequest uploadRequest, PortletResponse portletResponse) { PortletRequest actionRequest = (PortletRequest)uploadRequest.getAttribute( JavaConstants.JAVAX_PORTLET_REQUEST); boolean validate = true; if((Validator.isNotNull(uploadRequest.getParameter("numValidaciones")))&& (!Validator.isNumber(uploadRequest.getParameter("numValidaciones")))) { SessionErrors.add(actionRequest, "p2ptaskactivity.editActivity.numValidaciones.number"); validate=false; } return validate; }
public void serveResource( ResourceRequest request, ResourceResponse response) throws IOException, PortletException { PortletConfig portletConfig = (PortletConfig)request.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); String resourceId = request.getResourceID(); String portletId = portletConfig.getPortletName(); OutputUtils.servePortletFileEntry(portletId, resourceId, response); }
@Override public boolean especificValidations(UploadRequest uploadRequest, PortletResponse portletResponse) { if(!Validator.isNumber(PropsUtil.get("lms.course.default.evaluations"))) { return true; } PortletRequest portletRequest = (PortletRequest)uploadRequest.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); String numOfEvaluations = uploadRequest.getParameter("numOfEvaluations"); Long courseId = ParamUtil.getLong(uploadRequest, "courseId"); if (Validator.isNotNull(courseId)) { return true; } if(Validator.isNumber(numOfEvaluations)){ _numOfEvaluations.set(GetterUtil.getLong(numOfEvaluations)); return true; } if(Validator.isNull(numOfEvaluations)) { SessionErrors.add(portletRequest, "num-of-evaluations-required"); } else { SessionErrors.add(portletRequest, "num-of-evaluations-number"); } return false; }
/** * Obtém as preferências do portlet * * @return */ public static PortletPreferences getPortletPreferences() { HttpServletRequest req = getHttpServletRequest(); PortletRequest preq = (PortletRequest) req .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); return preq.getPreferences(); }
/** * Nunca deve ser chamado dentro de um método ON... * * @return */ public static RenderResponse getRenderResponse() { HttpServletRequest req = getHttpServletRequest(); RenderResponse rreq = (RenderResponse) req .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); return rreq; }
public TaskRecordSearch(PortletRequest portletRequest, String curParam, PortletURL iteratorURL) { super(portletRequest, new TaskRecordDisplayTerms(portletRequest), new TaskRecordSearchTerms(portletRequest), curParam, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE); PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); TaskRecordDisplayTerms displayTerms = (TaskRecordDisplayTerms) getDisplayTerms(); TaskRecordSearchTerms searchTerms = (TaskRecordSearchTerms) getSearchTerms(); String portletId = PortletProviderUtil.getPortletId(User.class.getName(), PortletProvider.Action.VIEW); String portletName = portletConfig.getPortletName(); if (!portletId.equals(portletName)) { displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED); searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED); } iteratorURL.setParameter(TaskRecordDisplayTerms.TASKRECORDID, String.valueOf(displayTerms.getTaskRecordId())); iteratorURL.setParameter(TaskRecordDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus())); iteratorURL.setParameter(TaskRecordDisplayTerms.WORK_PACKAGE, displayTerms.getWorkPackage()); iteratorURL.setParameter(TaskRecordDisplayTerms.DESCRIPTION, displayTerms.getDescription()); iteratorURL.setParameter(TaskRecordDisplayTerms.USER_NAME, displayTerms.getUserName()); iteratorURL.setParameter(TaskRecordDisplayTerms.TICKET_URL, displayTerms.getTicketURL()); iteratorURL.setParameter(TaskRecordDisplayTerms.CREATE_DATE, displayTerms.getCreateDate()); iteratorURL.setParameter(TaskRecordDisplayTerms.MODIFIED_DATE, displayTerms.getModifiedDate()); iteratorURL.setParameter(TaskRecordDisplayTerms.FROM_DATE, displayTerms.getFromDate()); iteratorURL.setParameter(TaskRecordDisplayTerms.UNTIL_DATE, displayTerms.getUntilDate()); iteratorURL.setParameter(TaskRecordDisplayTerms.DURATION, String.valueOf(displayTerms.getDuration())); try { PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest); String orderByCol = ParamUtil.getString(portletRequest, "orderByCol"); String orderByType = ParamUtil.getString(portletRequest, "orderByType"); if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) { preferences.setValue(portletId, "task-records-order-by-col", orderByCol); preferences.setValue(portletId, "task-records-order-by-type", orderByType); } else { orderByCol = preferences.getValue(portletId, "task-records-order-by-col", "modified-date"); orderByType = preferences.getValue(portletId, "task-records-order-by-type", "asc"); } setOrderableHeaders(orderableHeaders); if (Validator.isNotNull(orderableHeaders.get(orderByCol))) { setOrderByCol(orderableHeaders.get(orderByCol)); } else { _log.error(orderByCol + " is not an orderable header."); setOrderByCol(orderByCol); } setOrderByType(orderByType); } catch (Exception e) { _log.error(e); } }
public ContactSearch(PortletRequest portletRequest, String curParam, PortletURL iteratorURL) { super(portletRequest, new ContactDisplayTerms(portletRequest), new ContactSearchTerms(portletRequest), curParam, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE); PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); ContactDisplayTerms displayTerms = (ContactDisplayTerms) getDisplayTerms(); ContactSearchTerms searchTerms = (ContactSearchTerms) getSearchTerms(); String portletId = PortletProviderUtil.getPortletId(User.class.getName(), PortletProvider.Action.VIEW); String portletName = portletConfig.getPortletName(); if (!portletId.equals(portletName)) { displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED); searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED); } iteratorURL.setParameter(ContactDisplayTerms.COMPANY, String.valueOf(displayTerms.getCompany())); iteratorURL.setParameter(ContactDisplayTerms.CONTACT_ID, String.valueOf(displayTerms.getContactId())); iteratorURL.setParameter(ContactDisplayTerms.CREATE_DATE, String.valueOf(displayTerms.getCreateDate())); iteratorURL.setParameter(ContactDisplayTerms.EMAIL, String.valueOf(displayTerms.getEmail())); iteratorURL.setParameter(ContactDisplayTerms.FAX, String.valueOf(displayTerms.getFax())); iteratorURL.setParameter(ContactDisplayTerms.FULL_NAME, String.valueOf(displayTerms.getFullName())); // TODO: add default impp iteratorURL.setParameter(ContactDisplayTerms.MODIFIED_DATE, String.valueOf(displayTerms.getModifiedDate())); iteratorURL.setParameter(ContactDisplayTerms.NAME, String.valueOf(displayTerms.getName())); iteratorURL.setParameter(ContactDisplayTerms.PHONE, String.valueOf(displayTerms.getPhone())); iteratorURL.setParameter(ContactDisplayTerms.USER_NAME, String.valueOf(displayTerms.getUserName())); try { PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest); String orderByCol = ParamUtil.getString(portletRequest, "orderByCol"); String orderByType = ParamUtil.getString(portletRequest, "orderByType"); if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) { preferences.setValue(portletId, "contacts-order-by-col", orderByCol); preferences.setValue(portletId, "contacts-order-by-type", orderByType); } else { orderByCol = preferences.getValue(portletId, "contacts-order-by-col", "modified-date"); orderByType = preferences.getValue(portletId, "contacts-order-by-type", "asc"); } setOrderableHeaders(orderableHeaders); if (Validator.isNotNull(orderableHeaders.get(orderByCol))) { setOrderByCol(orderableHeaders.get(orderByCol)); } else { _log.error(orderByCol + " is not an orderable header."); setOrderByCol(orderByCol); } setOrderByType(orderByType); } catch (Exception e) { _log.error(e); } }
public MeasurementSearch(PortletRequest portletRequest, String curParam, PortletURL iteratorURL) { super(portletRequest, new MeasurementDisplayTerms(portletRequest), new MeasurementSearchTerms(portletRequest), curParam, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE); PortletConfig portletConfig = (PortletConfig) portletRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); MeasurementDisplayTerms displayTerms = (MeasurementDisplayTerms) getDisplayTerms(); MeasurementSearchTerms searchTerms = (MeasurementSearchTerms) getSearchTerms(); String portletId = PortletProviderUtil.getPortletId(User.class.getName(), PortletProvider.Action.VIEW); String portletName = portletConfig.getPortletName(); if (!portletId.equals(portletName)) { displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED); searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED); } iteratorURL.setParameter(MeasurementDisplayTerms.CREATE_DATE, displayTerms.getCreateDate()); iteratorURL.setParameter(MeasurementDisplayTerms.DATA, displayTerms.getData()); iteratorURL.setParameter(MeasurementDisplayTerms.MEASUREMENT_ID, String.valueOf(displayTerms.getMeasurementId())); iteratorURL.setParameter(MeasurementDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus())); iteratorURL.setParameter(MeasurementDisplayTerms.USER_NAME, displayTerms.getUserName()); iteratorURL.setParameter(MeasurementDisplayTerms.MODIFIED_DATE, displayTerms.getModifiedDate()); iteratorURL.setParameter(MeasurementDisplayTerms.FROM, String.valueOf(displayTerms.getFrom())); iteratorURL.setParameter(MeasurementDisplayTerms.UNTIL, String.valueOf(displayTerms.getUntil())); try { PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest); String orderByCol = ParamUtil.getString(portletRequest, "orderByCol"); String orderByType = ParamUtil.getString(portletRequest, "orderByType"); if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) { preferences.setValue(portletId, "measurements-order-by-col", orderByCol); preferences.setValue(portletId, "measurements-order-by-type", orderByType); } else { orderByCol = preferences.getValue(portletId, "measurements-order-by-col", "modified-date"); orderByType = preferences.getValue(portletId, "measurements-order-by-type", "asc"); } setOrderableHeaders(orderableHeaders); if (Validator.isNotNull(orderableHeaders.get(orderByCol))) { setOrderByCol(orderableHeaders.get(orderByCol)); } else { _log.error(orderByCol + " is not an orderable header."); setOrderByCol(orderByCol); } setOrderByType(orderByType); } catch (Exception e) { _log.error(e); } }
public PortletRequest getRequest() { return (PortletRequest) _uploadRequest.getAttribute( JavaConstants.JAVAX_PORTLET_REQUEST); }
public void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletConfig portletConfig = (PortletConfig)renderRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); String updateMessage = getUpdateMessage(portletConfig); renderRequest.setAttribute("updateMessage", updateMessage); List<String> outputList = IndexCheckerOutput.generateCSVOutput( portletConfig, renderRequest); String portletId = portletConfig.getPortletName(); long userId = PortalUtil.getUserId(renderRequest); String outputContent = OutputUtils.listStringToString(outputList); FileEntry exportCsvFileEntry = OutputUtils.addPortletOutputFileEntry( portletId, userId, outputContent); if (exportCsvFileEntry != null) { ResourceURL exportCsvResourceURL = renderResponse.createResourceURL(); exportCsvResourceURL.setResourceID(exportCsvFileEntry.getTitle()); renderRequest.setAttribute( "exportCsvResourceURL", exportCsvResourceURL.toString()); } try { List<Long> siteGroupIds = this.getSiteGroupIds(); renderRequest.setAttribute("groupIdList", siteGroupIds); List<String> groupDescriptionList = getSiteGroupDescriptions( siteGroupIds, renderRequest.getLocale()); renderRequest.setAttribute( "groupDescriptionList", groupDescriptionList); } catch (Exception e) { throw new PortletException(e); } try { List<Model> modelList = this.getModelList(); renderRequest.setAttribute("modelList", modelList); } catch (SystemException se) { throw new PortletException(se); } long filterModifiedDate = ParamUtil.getLong( renderRequest, "filterModifiedDate", 0L); renderRequest.setAttribute("filterModifiedDate", filterModifiedDate); super.doView(renderRequest, renderResponse); }
public UserSearchContainer( PortletRequest portletRequest, String curParam, PortletURL iteratorURL) { super( portletRequest, new UserDisplayTerms(portletRequest), new UserSearchTerms(portletRequest), curParam, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE); PortletConfig portletConfig = (PortletConfig)portletRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); UserDisplayTerms displayTerms = (UserDisplayTerms)getDisplayTerms(); UserSearchTerms searchTerms = (UserSearchTerms)getSearchTerms(); String portletName = portletConfig.getPortletName(); if (!portletName.equals(PortletKeys.USERS_ADMIN)) { displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED); searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED); } iteratorURL.setParameter( UserDisplayTerms.STATUS, Integer.toString(displayTerms.getStatus())); iteratorURL.setParameter( UserDisplayTerms.EMAIL_ADDRESS, displayTerms.getEmailAddress()); iteratorURL.setParameter( UserDisplayTerms.FIRST_NAME, displayTerms.getFirstName()); iteratorURL.setParameter( UserDisplayTerms.LAST_NAME, displayTerms.getLastName()); iteratorURL.setParameter( UserDisplayTerms.SCREEN_NAME, displayTerms.getScreenName()); iteratorURL.setParameter( UserDisplayTerms.TEAM, Long.toString(displayTerms.getTeamId())); try { PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences( portletRequest); String orderByCol = ParamUtil.getString( portletRequest, "orderByCol"); String orderByType = ParamUtil.getString( portletRequest, "orderByType"); if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) { preferences.setValue( PortletKeys.USERS_ADMIN, "users-order-by-col", orderByCol); preferences.setValue( PortletKeys.USERS_ADMIN, "users-order-by-type", orderByType); } else { orderByCol = preferences.getValue( PortletKeys.USERS_ADMIN, "users-order-by-col", "last-name"); orderByType = preferences.getValue( PortletKeys.USERS_ADMIN, "users-order-by-type", "asc"); } OrderByComparator orderByComparator = UsersAdminUtil.getUserOrderByComparator( orderByCol, orderByType); setOrderableHeaders(orderableHeaders); setOrderByCol(orderByCol); setOrderByType(orderByType); setOrderByComparator(orderByComparator); } catch (Exception e) { _log.error(e); } //Cargamos el displayTerms }
/** * Obtém as preferências do portlet * @return */ public static PortletPreferences getPortletPreferences() { HttpServletRequest req = getHttpServletRequest(); PortletRequest preq = (PortletRequest) req.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); return preq.getPreferences(); }
public static PortletRequest getPortletRequest(){ HttpServletRequest req = getHttpServletRequest(); PortletRequest preq = (PortletRequest) req.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); return preq; }
/** * Nunca deve ser chamado dentro de um método ON... * @return */ public static RenderResponse getRenderResponse(){ HttpServletRequest req = getHttpServletRequest(); RenderResponse rreq = (RenderResponse) req.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); return rreq; }
public static PortletRequest getPortletRequest() { HttpServletRequest req = getHttpServletRequest(); PortletRequest preq = (PortletRequest) req .getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); return preq; }