ioArgs in Dojo 1.10, dojox DialogSimple - post

Got myself a bit of a problem (only occurring in Tomcat 8.5, but I'll need to handle it)...
I'm trying to open up a dojox.widget.DialogSimple, using an href, that has a long url/data string. Setting the HREF on instantiation causes it to fail as a malformed URL, because it's too long. So, I want to be able to do it as an xhrPost. Is there a way to set this up using the ioArgs property? I haven't been able to find any documentation giving examples of this.

You are correct. An over-long URL string for an HTTP "GET" can cause problems: Web Services: maximum length of HTTP GET request?. In general, the solution is to do a "POST" instead.
Would this solution work for you?
Dojo - how to submit data using a Dialog form
<div dojotype="dijit.Dialog" id="subscription" title="subscription form" execute="alert('Transmitted');">
<form action="PATH_TO_PHP_PAGE" method="POST">
<!--input widgets-->
<!--submit button widgets-->
</form>
</div>

Related

How do I escape HTML for th:errors?

Let's say I have:
<span th:if="${#fields.hasErrors('firstName')}" class="color--error" th:errors="*{firstName}"></span>
How do I escape the text if the error text contains HTML? I know for normal text, we can use th:utext.
As of 3.0.8-SNAPSHOT, Thymeleaf-Spring has th:uerrors.
See this GitHub issue for the discussion: https://github.com/thymeleaf/thymeleaf-spring/issues/153
And this change log for 3.0.8: http://forum.thymeleaf.org/Thymeleaf-3-0-8-JUST-PUBLISHED-td4030687.html
th:errors is just a shortcut. You still use th:utext for this, you just have to manually output your errors. In your case, the code could look something like:
<div th:if="${#fields.hasErrors('firstName')}" th:each="err: ${#fields.errors('firstName')}" th:utext="${err}" class="color--error" />

doPost not working in Google app script

I came across various questions but none of them could solve my problem. I wrote a simple doPost() code in google app script:
function doPost(e){
Logger.log("Hello World");
}
Then I deployed it as a web app and pasted the url on hurl.it to make a post request. However, there is nothing being logged in the log and the response is 200 (Ok). I think it is not going inside this doPost() function. Can anyone guide as to what am I doing wrong here?
Your implementation does not meet all the requirements needed for a web app. Here's an excerpt from the documentation (link):
Requirements for web apps
A script can be published as a web app if it meets these requirements:
It contains a doGet(e) or doPost(e) function.
The function returns an HTML service HtmlOutput object or a content service TextOutput object.
Here are some examples:
function doGet(e) {
var params = JSON.stringify(e);
return HtmlService.createHtmlOutput(params);
}
function doPost(e) {
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
And just for completeness, you must also redeploy your web App as a new version every time you make changes to the code. Redeploying under an already existing version does not work, you have to make a new version for your changes to take hold.
Also using the standard Logger.log to trace changes within doGet(e) or doPost(e) is unreliable with web apps as they are executed asynchronously. I would recommend logging your output to a spreadsheet. There is an awesome script library called BetterLog that extends the Logger API to do just that; it can be found at the following link:
https://github.com/peterherrmann/BetterLog
UPDATE 2018-07-18
Apps Script now supports StackDriver Logging which is accessible from the Apps Scripts editor's View menu.
in order for the "exec" version of the published Web App URL to run with any new changes, you must publish a new version every time that you make a change to your script. It does not matter how small the change is. Instead of using Logger.log("Hello World"); I would write a value to a spreadsheet.
SpreadsheetApp.openById(id).getSheetByName(name).appendRow(['test']);
There are 2 different URL's for your Web App. One with 'dev' on the end and the other with 'exec' on the end. The 'dev' version is always the current code. The 'exec' version never changes unless you publish a new version.
I struggled with this for AWHILE NOW and I finally got lucky.
I use w3schools alot so I read fully on the form element and its attributes.
The ACTION attribute seems to be the key in getting doPost(e) to work for me and GAS.
Here's my HTML (removed opening and closing angle brackets)
<form
action="https://script.google.com/a/[org]/macros/s/[scriptID]/exec"
method="post" target="_blank" >
First name: input type="text" name="fname"<br>
Last name: input type="text" name="lname"<br>
input type="submit" value="Submit"
</form>
Here's my doPost ( the Logger ran as well as the new window displaying e.parameter)
function doPost(e){
Logger.log("I WAS RAN!!")
if(typeof e !== 'undefined') {
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
}
One of the reason can be you are using a Rest client like Postman. It won't work, though I don't know the reason why.
Try with a normal form like this and it will work:
<!DOCTYPE html>
<html>
<body>
<form action="https://script.google.com/macros/s/AKfyc.../exec">
First name:<br>
<input type="text" name="param1" value="ABC">
<br>
Last name:<br>
<input type="text" name="param2" value="XYZ">
<br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Hyperlink not clickable on Internet Explorer if use Url.Action

I used the mvc actionlink to get the url. It is working fine in chrome. But in IE it is not even clicking. i used the following code to navigate the page.
<a href="#Url.Action("GetHelpDocuments", "Document")">
<span class="navsprite helplink"></span>
<span>Help</span>
I don't find any error in my above code. But please give alternate solution for this.
I used localtion.href to get the actual location href
<a href="#Url.Action("GetHelpDocuments", "Document")" onclick='location.href = this.getAttribute("href")'>
<span class="navsprite helplink" ></span>
<span>Help</span>

Twitter share button not using custom url or text

I have a link like so
= link_to "https://twitter.com/share", class: "twitter-share-button", data: { url: "https://google.com", text: hack.body, via: "GhettoLifeHack_", hashtags: "ghettolifehack" } do
= image_tag "Tweet", alt: "Social Twitter tweet button"
and no matter how much I change the data-url value, the pre-tweet confirmation page always prepopulates the tweet form field with the url of the referring page, not the one I specified. It also ignores my custom data-text as well.
Why is this happening?
I also have this minified script
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
that I got from here https://about.twitter.com/resources/buttons#tweet
Removing that script doesn't seem to change anything.
edit: upon trying using :'data-url' attributes directly, the output html is the same.
I am testing hardcoded strings and dynamically generated urls at the same time. The first is the dynamic one.
<a class="twitter-share-button" href="https://twitter.com/share" data-via="GhettoLifeHack_" data-url="http://localhost:3000/hacks/1" data-text="asdf comment body" data-hashtags="ghettolifehack">
<img src="/images/Tweet" alt="Tweet" title=""></img>
</a>
The second is the hard coded strings
<a class="twitter-share-button" href="https://twitter.com/share" data-via="GhettoLifeHack_" data-url="httpL//google.com" data-text="custom text" data-hashtags="ghettolifehack">
<img src="/images/Tweet" alt="Tweet" title=""></img>
</a>
I've tested on development and in production. Both have the same behavior of pre-populating the tweet form with the referring url, rather than the specified url and text.
This works in Chrome for me but not in Firefox 32
The code provided by you is perfectly fine and should work as expected.
Many site issues can be caused by corrupt cookies or cache. Try to clear both cookies and the cache. I would suggest you to look into the following link to see why it is not working in firefox
The issue was specific to firefox browser. I'm not sure what addon or setting is causing the conflicts, but it is working perfectly find in chrome, including the popup window.

Create TYPO3 Fluid link for typolink fields generated by a link wizard

I regularly use the link wizard in my TCA.
Its horrible to find out with conditions which kind of link I have to render in Fluid (page/email/external). Is there a solution for this or do I have to create my own ViewHelper?
It seems to be undocumented, but you can pass it to <f:link.page> and it will be rendered correctly, even if it is external, email, or file link. This is because internally, <f:link.page> uses UriBuilder to build the URL, and that UriBuilder uses Typolink.
<f:link.page pageUid="{myLinkFieldValue}">My link</f:link.page>
This is the ViewHelper i´m using for this (+a helper Class):
https://gist.github.com/BenjaminBeck/7220623
I think the link.typolink ViewHelper is what you are looking for, at least for TYPO3 7.0 and above.
<f:link.typolink parameter="{link}">
Linktext
</f:link.typolink>
See Changelog Feature #59396 - TypolinkViewHelper (TYPO3 7.0)
see link.typolink in ViewHelper Reference
External Link --
<f:link.external uri="http://www.typo3.org" target="_blank">external link</f:link.external>
Email --
<f:link.email additionalAttributes="{foo: 'bar'}" email="NULL" class="NULL" dir="NULL" id="NULL" lang="NULL" style="NULL" title="NULL" accesskey="NULL" tabindex="123" onclick="NULL" name="NULL" rel="NULL" rev="NULL" target="NULL">
<!-- tag content - may be ignored! -->
</f:link.email>
Internal Link --
<f:link.page pageUid="1" additionalParams="{extension_key: {foo: 'bar'}}">page link</f:link.page>
In Fluid, there are different link view helpers:
<f:link.action action="show">action link</f:link.action>
<f:link.email email="foo#bar.tld" />
<f:link.external uri="http://www.typo3.org" target="_blank">external link</f:link.external>
<f:link.page>page link</f:link.page>
The Code (and some examples) can be found at: typo3/sysext/fluid/Classes/ViewHelpers/Link

Resources