@Override public void doBeforeRender(HstRequest request, HstResponse response) { // TODO Auto-generated method stub super.doBeforeRender(request, response); log.error("This is Member Home Page"); String status = getPublicRequestParameter(request, "status"); if (status != null && status.equals("success")) { request.setAttribute( "status", "You have successfully submit the Personal &Contact Information"); } String error = getPublicRequestParameter(request, "error"); if (error != null && error.equals("assessyear")) { request.setAttribute("assess_year_error", "Please Enter the assessment year"); } Member member = (Member) request.getSession().getAttribute("user"); Collection<String> oldpan = member.getPAN(); if (!oldpan.isEmpty()) { request.setAttribute("oldpan", oldpan.toArray(new String[oldpan.size()])); } ResolvedSiteMapItem resolvedSiteMapItem = request.getRequestContext().getResolvedSiteMapItem(); log.error( "resolvedSiteMapItem.getRelativeContentPath():" + resolvedSiteMapItem.getRelativeContentPath()); log.error( "resolvedSiteMapItem.getRelativeContentPath():" + resolvedSiteMapItem.getHstSiteMapItem().getRelativeContentPath()); // String test= getContentBean(request).getPath(); // log.warn("path"+test); List<MemberPersonalInformation> mperinfo = new ArrayList<MemberPersonalInformation>(); List<MemberContactInformation> mconinfo = new ArrayList<MemberContactInformation>(); for (String t : oldpan) { try { log.warn("in try"); MemberPersonalInformation pidocument = (MemberPersonalInformation) getObjectBeanManager(request) .getObject( "/content/documents/mootlywcm/members/pans/" + t + "/personalinformation/personalinformation"); MemberContactInformation cidocument = (MemberContactInformation) getObjectBeanManager(request) .getObject( "/content/documents/mootlywcm/members/pans/" + t + "/contactinformation/contactinformation"); mperinfo.add(pidocument); mconinfo.add(cidocument); } catch (ObjectBeanManagerException e) { // TODO Auto-generated catch block e.printStackTrace(); } } request.setAttribute("mperinfo", mconinfo); request.setAttribute("mconinfo", mconinfo); }
/** * Generate the trailing breadcrumb items. By default, the trailing items are derived from the * bean structure of the resolved sitemap item of the current request. * * @param request * @param deepestMenuItem * @return list of trailing breadcrumb items */ protected List<BreadcrumbItem> getTrailingBreadcrumbItems( HstRequest request, HstSiteMenuItem menuItem) { List<BreadcrumbItem> items = new ArrayList<BreadcrumbItem>(); ResolvedSiteMapItem currentSmi = request.getRequestContext().getResolvedSiteMapItem(); HippoBean currentBean = getComponent().getBeanForResolvedSiteMapItem(request, currentSmi); if (currentBean != null) { if (addTrailingDocumentOnly) { if (currentBean instanceof HippoDocument) { items.add(getBreadcrumbItem(request, currentBean)); } } else { ResolvedSiteMapItem menuItemSmi = menuItem.resolveToSiteMapItem(request); HippoBean menuItemBean = getComponent().getBeanForResolvedSiteMapItem(request, menuItemSmi); // parent steps based on ancestor bean if (menuItemBean != null && menuItemBean.isAncestor(currentBean)) { while (!currentBean.isSelf(menuItemBean)) { items.add(getBreadcrumbItem(request, currentBean)); currentBean = currentBean.getParentBean(); } } // try to determine parent steps based on path info in case the // menuItemBean is not an ancestor, which occurs for instance // when faceted navigation is used on the menu item else { String ancestorPath = menuItemSmi.getPathInfo(); String currentPath = currentSmi.getPathInfo(); if (currentPath.startsWith(ancestorPath)) { String trailingPath = currentPath.substring(ancestorPath.length()); if (trailingPath.startsWith("/")) { trailingPath = trailingPath.substring(1); } int steps = trailingPath.split("/").length; for (int i = 0; i < steps; i++) { items.add(getBreadcrumbItem(request, currentBean)); currentBean = currentBean.getParentBean(); } } } Collections.reverse(items); } } return items; }
/** * Sets {@code HttpServletResponse.SC_NOT_FOUND} error code onto request. * * @param response * @see javax.servlet.http.HttpServletResponse#SC_NOT_FOUND */ public void pageNotFound(HstResponse response) { final HstRequestContext context = RequestContextProvider.get(); String pageNotFoundPath = getComponentParameter(PAGE_404); if (Strings.isNullOrEmpty(pageNotFoundPath)) { pageNotFoundPath = PAGE_404; } final HippoBean bean = context.getSiteContentBaseBean().getBean(pageNotFoundPath, HippoBean.class); response.setStatus(HttpServletResponse.SC_NOT_FOUND); if (bean != null) { final HstLinkCreator hstLinkCreator = context.getHstLinkCreator(); final HstLink hstLink = hstLinkCreator.create(bean.getNode(), context); try { response.sendRedirect(hstLink.toUrlForm(context, false)); } catch (IOException e) { log.warn("Error redirecting to 404 page: [{}]", PAGE_404); } } else { // check if we have pagenotfound config final ResolvedSiteMapItem resolvedSiteMapItem = RequestContextProvider.get().getResolvedSiteMapItem(); if (resolvedSiteMapItem == null) { return; } final HstSiteMap siteMap = resolvedSiteMapItem.getHstSiteMapItem().getHstSiteMap(); final HstSiteMapItem pagenotfound = siteMap.getSiteMapItemByRefId(PAGE_NOT_FOUND); if (pagenotfound != null) { String link = pagenotfound.getValue(); try { response.forward('/' + link); } catch (IOException e) { log.error("Error forwarding to " + PAGE_NOT_FOUND + " page", e); } } } }