Skip to content

Commit

Permalink
Merge pull request #16 from davidblasby/_pr7154_demoRequest
Browse files Browse the repository at this point in the history
Pr7154 demo request
  • Loading branch information
bradh authored Aug 8, 2024
2 parents 6866a7e + 5189fea commit 5cab54f
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<body>
<wicket:extend>
<form wicket:id="form">
<input type="text" wicket:id="xml" id="xml" name="xml" style="display: none"></input>
<input type="text" wicket:id="xml" id="xml" name="xml"></input>

<div wicket:id="requestBuilder"></div>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import javax.xml.transform.TransformerException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptContentHeaderItem;
import org.apache.wicket.markup.html.form.Form;
Expand Down Expand Up @@ -210,6 +210,7 @@ public void renderHead(IHeaderResponse response) {
response.render(
JavaScriptContentHeaderItem.forScript(
DemoRequestsPage.demoRequestsJavascript, null));
response.render(CssHeaderItem.forCSS("#xml {display: none;}", "wpsRequestBuilderCSS"));
}

public class WPSRequestModel implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ <h2><a wicket:id="home" class="pngfix" href="#"></a></h2>
<button class="positive icon" type="submit">
<div><img src="#" wicket:id="link.icon"/><span wicket:id="link.label"></span></div>
</button>
<script type="text/javascript">
$('input, textarea').placeholder();
</script>
</form>
</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.wicket.markup.head.CssReferenceHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.head.PriorityHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
Expand Down Expand Up @@ -533,6 +534,10 @@ public void renderHead(IHeaderResponse response) {
new PackageResourceReference(
GeoServerBasePage.class, "js/jquery.hide.ajaxFeedback.js")));

// due to Content-security-policy, JS must be rendered by Wicket. This inits the textboxes
// for placeholders.
response.render(OnDomReadyHeaderItem.forScript("$('input, textarea').placeholder();"));

List<HeaderContribution> cssContribs =
getGeoServerApplication().getBeansOfType(HeaderContribution.class);
for (HeaderContribution csscontrib : cssContribs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@
</tr>
<tr>
<td class="label"><wicket:message key="userName">User Name:</wicket:message></td>
<td class="datum"><input type="text" size="30" name="username" wicket:id="username" class="text" style="width: 120px;"/>
<td class="datum"><input id="inputUsername" type="text" size="30" name="username" wicket:id="username" class="text"/>
<wicket:message key="password">Password:</wicket:message>
<input type="password" size="30" name="password" wicket:id="password" class="text w-120px"/>
</td>
</tr>
<tr>
<td class="label" style="width:1%"></td>
<td class="label tdNoWidth"></td>
<td class="datum w-99pct">
<div style="display:flex; flex-direction: row">
<div id="divNewWindow">
<div class="button-group selfclear">
<a onclick="document.getElementById('openNewWindow').checked = false; submitRequest()" ><wicket:message key="submit">Submit</wicket:message></a>
<a id="linkSubmit" ><wicket:message key="submit">Submit</wicket:message></a>
</div>

<div class="button-group selfclear">
<a onclick="document.getElementById('openNewWindow').checked = true;submitRequest()" ><wicket:message key="openNewWindow">openNewWindow</wicket:message></a>
<a id="linkSubmitNewWin" ><wicket:message key="openNewWindow">openNewWindow</wicket:message></a>
</div>
</div>
</td>
</tr>
<tr style="display:none">
<tr id="trNewWindow">
<td><wicket:message key="openNewWindow">openNewWindow:</wicket:message></td>
<td><input type="checkbox" id="openNewWindow" wicket:id="openNewWindow" name="openNewWindow"></td>
</tr>
Expand All @@ -74,13 +74,13 @@
<legend>
<span><wicket:message key="headers">openNewWindow:</wicket:message></span>
</legend>
<div id="responseHeadersDiv" style="min-height: 15px;margin-bottom:7px">
<div id="responseHeadersDiv">
</div>
<legend>
<span><wicket:message key="result">result:</wicket:message></span>
</legend>

<div id="responseDiv" style="min-height: 15px">
<div id="responseDiv">
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptContentHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
Expand Down Expand Up @@ -63,6 +65,13 @@ public class DemoRequestsPage extends GeoServerBasePage {
*/
public static String demoRequestsJavascript;

/**
* Style sheet (Content-Security-Policy does not allow inline-styles)
*
* <p>See static block, below.
*/
public static String demoRequestsCSS;

static {
try {
var demo_request_js =
Expand All @@ -79,6 +88,14 @@ public class DemoRequestsPage extends GeoServerBasePage {
Charsets.UTF_8));
var js = demo_request_js + "\n" + xml_pretty_print_js;
demoRequestsJavascript = js;

demoRequestsCSS =
CharStreams.toString(
new InputStreamReader(
DemoRequestsPage.class.getResourceAsStream(
"/org/geoserver/web/demo/demo-requests.css"),
Charsets.UTF_8));

} catch (Exception e) {
LOGGER.log(Level.SEVERE, "error occurred reading demoRequestsJavascript", e);
}
Expand Down Expand Up @@ -116,6 +133,18 @@ public DemoRequestsPage(PageParameters parameters) {
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(JavaScriptContentHeaderItem.forScript(demoRequestsJavascript, null));
response.render(CssHeaderItem.forCSS(demoRequestsCSS, "demoRequestsCSS"));

// setup onClick events (Content-security-policy doesn't allow onClick events in the HTML)
String script = "\n";

script +=
"$('#linkSubmit').on('click',function() {\ndocument.getElementById('openNewWindow').checked = false; \nsubmitRequest();\n} \n);\n\n";
script +=
"$('#linkSubmitNewWin').on('click',function() {\ndocument.getElementById('openNewWindow').checked = true;\nsubmitRequest();\n} );\n\n";

script += "\n";
response.render(OnDomReadyHeaderItem.forScript(script));
}

public void setup() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#responseDiv {
min-height: 15px;
}

#responseHeadersDiv {
min-height: 15px;
margin-bottom:7px;
}

#trNewWindow {
display:none;
}

#divNewWindow {
display:flex;
flex-direction: row;
}

tdNoWidth {
width: 1%;
}

#inputUsername {
width: 120px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<wicket:extend>

<form wicket:id="form">
<input type="text" wicket:id="xml" id="xml" name="xml" style="display: none"></input>
<input type="text" wicket:id="xml" id="xml" name="xml"></input>
<div wicket:id="requestBuilder"></div>
<ul>
<li class="button-group selfclear">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import javax.xml.transform.TransformerException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptContentHeaderItem;
import org.apache.wicket.markup.html.form.Form;
Expand Down Expand Up @@ -195,6 +195,8 @@ public void renderHead(IHeaderResponse response) {
response.render(
JavaScriptContentHeaderItem.forScript(
DemoRequestsPage.demoRequestsJavascript, null));

response.render(CssHeaderItem.forCSS("#xml {display: none;}", "wcsRequestBuilderCSS"));
}

public class WCSRequestModel implements Serializable {
Expand Down

0 comments on commit 5cab54f

Please sign in to comment.