Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WW-5241] Fixes issue with includeParams=all when using exec & wait #611

Merged
merged 4 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/showcase/src/main/resources/struts-wait.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<bean type="org.apache.struts2.interceptor.exec.ExecutorProvider" class="org.apache.struts2.showcase.wait.ThreadPoolExecutorProvider"/>

<package name="wait" extends="struts-default" namespace="/wait">
<default-action-ref name="index"/>
<action name="index">
<result>/WEB-INF/wait/index.jsp</result>
</action>

<action name="example1">
<result>/WEB-INF/wait/example1.jsp</result>
Expand Down
2 changes: 1 addition & 1 deletion apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
</li>
<li><s:a value="/person/index.html">Person Manager</s:a></li>
<li><s:a value="/skill/index.html">CRUD</s:a></li>
<li><s:a value="/wait/index.html">Execute &amp; Wait</s:a></li>
<li><s:a value="/wait/index">Execute &amp; Wait</s:a></li>
<li><s:a value="/token/index.html">Token</s:a></li>
<li><s:url var="url" namespace="/modelDriven" action="modelDriven"/><s:a
href="%{url}">Model Driven</s:a></li>
Expand Down
29 changes: 15 additions & 14 deletions apps/showcase/src/main/webapp/WEB-INF/wait/complete.jsp
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - Execute and Wait Examples - Complete</title>
<title>Struts2 Showcase - Execute and Wait Examples - Complete</title>
</head>

<body>
<div class="page-header">
<h1>The process is complete</h1>
<h1>The process is complete</h1>
</div>


<div class="container-fluid">
<div class="row">
<div class="col-md-12" style="text-align: center;">
<div class="row">
<div class="col-md-12" style="text-align: center;">

<b>We have processed your request.</b>
<p/>
Click here to <s:url var="back" value="/wait/index.html"/><s:a href="%{back}" cssClass="btn btn-link">return</s:a>.
<div class="panel">We have processed your request.</div>

</div>
</div>
<s:url var="back" value="/wait/index"/>
Click here to <s:a href="%{back}" cssClass="btn btn-primary">return</s:a>

</div>
</div>
</div>
</body>
</html>
53 changes: 53 additions & 0 deletions apps/showcase/src/main/webapp/WEB-INF/wait/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
/*
* 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.
*/
-->
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - Execute and Wait Examples</title>
</head>

<body>
<div class="page-header">
<h1>Execute and Wait Examples</h1>
</div>

<div class="container-fluid">
<div class="row">
<div class="col-md-12" style="text-align: center;">

<p>
These examples illustrate Struts build in support for execute and wait.
<p/>
<p>
When you have a process that takes a long time your users can be impatient and starts to submit/click
again.
<br/> A good solution is to show the user a progress page (wait page) while the process takes it time.
<p/>

<br/>
<br/><a href='<s:url value="example1"/>'>Example 1 (no delay)</a>
<br/><a href='<s:url value="example2"/>'>Example 2 (with delay)</a>
<br/><a href='<s:url value="example3"/>'>Example 3 (with longer check delay)</a>
</div>
</div>
</div>
</body>
</html>
68 changes: 24 additions & 44 deletions apps/showcase/src/main/webapp/WEB-INF/wait/wait.jsp
Original file line number Diff line number Diff line change
@@ -1,73 +1,53 @@
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* 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
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - Execute and Wait Examples - Wait</title>
<title>Struts2 Showcase - Execute and Wait Examples - Wait</title>
<meta http-equiv="refresh" content="5;url=<s:url includeParams="all"/>"/>
</head>

<body>
<div class="page-header">
<h1>Execute and Wait Examples - Wait</h1>
<h1>Execute and Wait Examples - Wait</h1>
</div>


<div class="container-fluid">
<div class="row">
<div class="col-md-12" style="text-align: center;">

<p class="well">
We are processing your request. Please wait.
</p>

<div class="progress progress-striped active">
<div class="bar" style="width: 50%;"></div>
</div>

<p/>
You can click this link to <a href="<s:url includeParams="all"/>">refresh</a>.

<b>We have processed your request.</b>
<p/>
Click here to <s:url var="back" value="/wait/index.html"/><s:a href="%{back}" cssClass="btn btn-link">return</s:a>.

</div>
</div>
<div class="row">
<div class="col-md-12" style="text-align: center;">

<p class="well">
We are processing your request. Please wait.
</p>

<div class="progress progress-striped active">
<div class="bar progress-bar progress-bar-success" style="width: 50%;"></div>
</div>

<div class="panel">
You can click this link to <a href="<s:url includeParams="all"/>">refresh</a>.
</div>
</div>
</div>
</div>
</body>
</html>

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="refresh" content="5;url=<s:url includeParams="all"/>"/>
</head>

<body>
<p style="border: 1px solid silver; padding: 5px; background: #ffd; text-align: center;">
We are processing your request. Please wait.
</p>

<p/>
You can click this link to <a href="<s:url includeParams="all"/>">refresh</a>.

</body>
</html>
53 changes: 0 additions & 53 deletions apps/showcase/src/main/webapp/wait/index.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
import org.apache.struts2.util.PrefixTrie;

import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

/**
Expand Down Expand Up @@ -344,8 +349,8 @@ public void handleSpecialParameters(HttpServletRequest request, ActionMapping ma
/**
* Parses the name and namespace from the uri
*
* @param uri The uri
* @param mapping The action mapping to populate
* @param uri The uri
* @param mapping The action mapping to populate
* @param configManager configuration manager
*/
protected void parseNameAndNamespace(String uri, ActionMapping mapping, ConfigurationManager configManager) {
Expand Down Expand Up @@ -453,10 +458,14 @@ protected String cleanupMethodName(final String rawMethodName) {
/**
* Reads defined method name for a given action from configuration
*
* @param mapping current instance of {@link ActionMapping}
* @param mapping current instance of {@link ActionMapping}
* @param configurationManager current instance of {@link ConfigurationManager}
*/
protected void extractMethodName(ActionMapping mapping, ConfigurationManager configurationManager) {
if (mapping.getMethod() != null && allowDynamicMethodCalls) {
LOG.debug("DMI is enabled and method has been already mapped based on bang operator");
return;
}
String methodName = null;
for (PackageConfig cfg : configurationManager.getConfiguration().getPackageConfigs().values()) {
if (cfg.getNamespace().equals(mapping.getNamespace())) {
Expand Down Expand Up @@ -507,7 +516,7 @@ protected String dropExtension(String name, ActionMapping mapping) {
}

/**
* @return null if no extension is specified.
* @return null if no extension is specified.
*/
protected String getDefaultExtension() {
if (extensions == null) {
Expand Down Expand Up @@ -552,17 +561,19 @@ protected void handleName(ActionMapping mapping, StringBuilder uri) {
}

protected void handleDynamicMethod(ActionMapping mapping, StringBuilder uri) {
if (!allowDynamicMethodCalls) {
LOG.debug("DMI is disabled, ignoring appending !method to the URI");
return;
}
// See WW-3965
if (StringUtils.isNotEmpty(mapping.getMethod())) {
if (allowDynamicMethodCalls) {
// handle "name!method" convention.
String name = mapping.getName();
if (!name.contains("!")) {
// Append the method as no bang found
uri.append("!").append(mapping.getMethod());
}
} else {
// handle "name!method" convention.
String name = mapping.getName();
if (!name.contains("!")) {
// Append the method as no bang found
uri.append("!").append(mapping.getMethod());
} else if (name.endsWith("!")) {
uri.append(mapping.getMethod());
}
}
}
Expand Down
Loading