public ContributionCommentSuccessPage(PageParameters parameters) { super(parameters); contributionId = parameters.getInt("contribution"); boolean success = HibernateUtils.wrapTransaction( getHibernateSession(), new HibernateTask() { public boolean run(Session session) { contribution = (Contribution) session .createQuery("select c from Contribution as c where c.id = :id") .setInteger("id", contributionId) .uniqueResult(); return true; } }); if (!success) { logger.info("unknown contribution of id " + contributionId); throw new RestartResponseAtInterceptPageException(NotFoundPage.class); } initializeLocation(getNavMenu().getLocationByKey("teacherIdeas")); add( new LocalizedText( "comment-header", "contribution.comment.success", new Object[] {HtmlUtils.encode(contribution.getTitle())})); add( new LocalizedText( "comment-success", "contribution.comment.successRedirection", new Object[] { ContributionPage.getLinker(contributionId).getHref(getPageContext(), getPhetCycle()), REDIRECTION_DELAY_SECONDS })); Label redirector = new Label("redirector", ""); redirector.add( new AttributeModifier( "content", true, new Model<String>( REDIRECTION_DELAY_SECONDS + ";url=" + ContributionPage.getLinker(contributionId) .getRawUrl(getPageContext(), getPhetCycle())))); add(redirector); setTitle( StringUtils.messageFormat( PhetLocalizer.get().getString("contribution.comment.success", this), new Object[] {HtmlUtils.encode(contribution.getTitle())})); }
public SimulationFAQPage(PageParameters parameters) { super(parameters); final String simName = parameters.getString("simulation"); Result<FAQList> faqListResult = HibernateUtils.resultCatchTransaction( getHibernateSession(), new Task<FAQList>() { public FAQList run(Session session) { LocalizedSimulation lsim = HibernateUtils.getBestSimulation(session, getMyLocale(), simName); simTitle = lsim.getTitle(); Simulation simulation = lsim.getSimulation(); if (!simulation.isFaqVisible() || simulation.getFaqList() == null) { throw new TaskException("Simulation does not have a FAQ visible"); } return simulation.getFaqList(); } }); if (!faqListResult.success) { throw new RestartResponseAtInterceptPageException(NotFoundPage.class); } // TODO: better way of handling look-ups for message-formatted strings (with locales). // consolidate into PhetLocalizer String title = StringUtils.messageFormat( getPhetLocalizer().getString("simulation.faq.title", this), new Object[] {simTitle}, getMyLocale()); setTitle(title); add(new Label("faq-header", title)); // TODO: meta description! // setMetaDescription( ogDescription ); add(new FAQPanel("faq-panel", faqListResult.value.getName(), getPageContext())); initializeLocationWithSet(new ArrayList<NavLocation>()); }