Author: tchemit Date: 2012-03-28 10:56:35 +0200 (Wed, 28 Mar 2012) New Revision: 3214 Url: http://chorem.org/repositories/revision/pollen/3214 Log: add result to avoid the : void mystery + add svn properties Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-28 07:59:26 UTC (rev 3213) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java 2012-03-28 08:56:35 UTC (rev 3214) @@ -1,3 +1,26 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ package org.chorem.pollen.ui.actions; import org.apache.struts2.util.StrutsTypeConverter; Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/BooleanIntegerConverter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-28 07:59:26 UTC (rev 3213) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java 2012-03-28 08:56:35 UTC (rev 3214) @@ -1,3 +1,26 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ package org.chorem.pollen.ui.actions; import com.google.common.base.Preconditions; Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollUriConverter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java 2012-03-28 08:56:35 UTC (rev 3214) @@ -0,0 +1,231 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +/* + * $Id$ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.chorem.pollen.ui.results; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.config.entities.ResultConfig; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; +import org.apache.struts2.ServletActionContext; +import org.apache.struts2.dispatcher.Dispatcher; +import org.apache.struts2.dispatcher.ServletActionRedirectResult; +import org.apache.struts2.dispatcher.ServletRedirectResult; +import org.apache.struts2.dispatcher.mapper.ActionMapper; +import org.apache.struts2.dispatcher.mapper.ActionMapping; +import org.apache.struts2.views.util.UrlHelper; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * <!-- START SNIPPET: description --> + * <p/> + * This result uses the {@link ActionMapper} provided by the + * {@link ActionMapperFactory} to redirect the browser to a URL that invokes the + * specified action and (optional) namespace. This is better than the + * {@link ServletRedirectResult} because it does not require you to encode the + * URL patterns processed by the {@link ActionMapper} in to your struts.xml + * configuration files. This means you can change your URL patterns at any point + * and your application will still work. It is strongly recommended that if you + * are redirecting to another action, you use this result rather than the + * standard redirect result. + * <p/> + * See examples below for an example of how request parameters could be passed + * in. + * <p/> + * <!-- END SNIPPET: description --> + * <p/> + * <b>This result type takes the following parameters:</b> + * <p/> + * <!-- START SNIPPET: params --> + * <p/> + * <ul> + * <p/> + * <li><b>actionName (default)</b> - The name of the action that will be + * redirected to.</li> + * <p/> + * <li><b>namespace</b> - Used to determine which namespace the action is in + * that we're redirecting to. If namespace is null, the default will be the + * current namespace.</li> + * <p/> + * <li><b>suppressEmptyParameters</b> - Optional boolean (defaults to false) that + * can prevent parameters with no values from being included in the redirect + * URL.</li> + * <p/> + * <li><b>parse</b> - Boolean, true by default. If set to false, the actionName + * param will not be parsed for Ognl expressions.</li> + * <p/> + * <li><b>anchor</b> - Optional. Also known as "fragment" or colloquially as + * "hash". You can specify an anchor for a result.</li> + * </ul> + * <p/> + * <!-- END SNIPPET: params --> + * <p/> + * <b>Example:</b> + * <p/> + * <pre> + * <!-- START SNIPPET: example --> + * <package name="public" extends="struts-default"> + * <action name="login" class="..."> + * <!-- Redirect to another namespace --> + * <result type="redirectAction"> + * <param name="actionName">dashboard</param> + * <param name="namespace">/secure</param> + * </result> + * </action> + * </package> + * + * <package name="secure" extends="struts-default" namespace="/secure"> + * <-- Redirect to an action in the same namespace --> + * <action name="dashboard" class="..."> + * <result>dashboard.jsp</result> + * <result name="error" type="redirectAction">error</result> + * </action> + * + * <action name="error" class="..."> + * <result>error.jsp</result> + * </action> + * </package> + * + * <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters"> + * <!-- Pass parameters (reportType, width and height) --> + * <!-- + * The redirectAction url generated will be : + * /genReport/generateReport.action?reportType=pie&width=100&height=100#summary + * --> + * <action name="gatherReportInfo" class="..."> + * <result name="showReportResult" type="redirectAction"> + * <param name="actionName">generateReport</param> + * <param name="namespace">/genReport</param> + * <param name="reportType">pie</param> + * <param name="width">100</param> + * <param name="height">100</param> + * <param name="empty"></param> + * <param name="suppressEmptyParameters">true</param> + * <param name="anchor">summary</param> + * </result> + * </action> + * </package> + * + * + * <!-- END SNIPPET: example --> + * </pre> + * + * @see ActionMapper + */ +public class PollenServletActionRedirectResult extends ServletActionRedirectResult { + + private static final long serialVersionUID = -9042425229314584066L; + + private static final Logger LOG = + LoggerFactory.getLogger(ServletRedirectResult.class); + + /** + * Redirects to the location specified by calling + * {@link HttpServletResponse#sendRedirect(String)}. + * + * @param finalLocation the location to redirect to. + * @param invocation an encapsulation of the action execution state. + * @throws Exception if an error occurs when redirecting. + */ + protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { + ActionContext ctx = invocation.getInvocationContext(); + HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST); + HttpServletResponse response = (HttpServletResponse) ctx.get(ServletActionContext.HTTP_RESPONSE); + +// if (isPathUrl(finalLocation)) { + if (!finalLocation.startsWith("/")) { + ActionMapping mapping = actionMapper.getMapping(request, Dispatcher.getInstance().getConfigurationManager()); + String namespace = null; + if (mapping != null) { + namespace = mapping.getNamespace(); + } + + if ((namespace != null) && (namespace.length() > 0) && (!"/".equals(namespace))) { + finalLocation = namespace + "/" + finalLocation; + } else { + finalLocation = "/" + finalLocation; + } + } + + // if the URL's are relative to the servlet context, append the servlet context path + if (prependServletContext && (request.getContextPath() != null) && (request.getContextPath().length() > 0)) { + finalLocation = request.getContextPath() + finalLocation; + } + + ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode()); + if (resultConfig != null) { + Map<String, String> resultConfigParams = resultConfig.getParams(); + + for (Map.Entry<String, String> e : resultConfigParams.entrySet()) { + if (!getProhibitedResultParams().contains(e.getKey())) { + String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue(), invocation); + if (!suppressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) { + requestParameters.put(e.getKey(), potentialValue); + } + } + } + } + + StringBuilder tmpLocation = new StringBuilder(finalLocation); + UrlHelper.buildParametersString(requestParameters, tmpLocation, "&"); + + // add the anchor + if (anchor != null) { + tmpLocation.append('#').append(anchor); + } + + finalLocation = response.encodeRedirectURL(tmpLocation.toString()); +// } + + if (LOG.isDebugEnabled()) { + LOG.debug("Redirecting to finalLocation " + finalLocation); + } + + sendRedirect(response, finalLocation); + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/results/PollenServletActionRedirectResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 07:59:26 UTC (rev 3213) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-03-28 08:56:35 UTC (rev 3214) @@ -34,7 +34,7 @@ <result-types> <result-type name="redirectToVote" - class="org.apache.struts2.dispatcher.ServletActionRedirectResult"> + class="org.chorem.pollen.ui.results.PollenServletActionRedirectResult"> <param name="namespace">/poll</param> <param name="actionName">votefor/${uriId}</param> </result-type> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-28 07:59:26 UTC (rev 3213) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties 2012-03-28 08:56:35 UTC (rev 3214) @@ -1 +1,24 @@ +### +# #%L +# Pollen :: UI (strust2) +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2012 CodeLutin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# #L% +### voteValue=org.chorem.pollen.ui.actions.BooleanIntegerConverter \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/business/persistence/VoteToChoice-conversion.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-28 07:59:26 UTC (rev 3213) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties 2012-03-28 08:56:35 UTC (rev 3214) @@ -1 +1,24 @@ +### +# #%L +# Pollen :: UI (strust2) +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2009 - 2012 CodeLutin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# #L% +### uriId=org.chorem.pollen.ui.actions.PollUriConverter \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction-conversion.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native