POST request in GWT - gwt

i first tried to make request to server with GET method and it works fine. my request would process a file then return as a pdf file and would open on a new browser. what i did is overriding the doGet() method. since having a GET request is only limited to few parameters, i must change it to doPost() mehod but the problem is that it can't be overrided because the method is final.
in an HTML FORM, what i wanted to happen is something like this:
<form method="post" action="http://differentdomain.com/appserv/appserv.php">
<input type="hidden" name="fwi_script" value="app/custom/cusapp/interface" />
<input type="hidden" name="trx" value="<trx>
<productid>PROD1</productid>
....../** transaction details here */
</trx>" />
<input type="hidden" name="fcompanyid" value="SHOST101" />
<input type="hidden" name="fwi_action" value="PRINT_PENDING_SALES" />
<input type="hidden" name="fexcel" value="0" />
<input type="submit" value="Submit" />
</form>
this html form will print the order slip of every transaction when user clicks on the post order button.
anyone can give an idea on how to POST request in GWT server? i think i can't do it with RequestBuilder since i will be having the SOP problem since i will be connecting to a different domain.

To build very nearly the same html you have in your question, start with a FormPanel and add the form fields you need to it. Make sure to configure the FormPanel with the correct action and method, and to provide names (and possibly values) to the fields added to it. To fire off the request, submit() can be called.

The solution is to make a normal GWT RPC call to your server and have the server make the POST request to the server located on a different domain.

Related

Creating a case from Microsoft Forms into Salesforce

Is there a way to take responses filled in Microsoft Forms and create a case into Salesforce?
I have not gathered enough information to attempt this problem.
I can answer from SF side, you'll have to translate to MS world.
Salesforce offers somewhat dated but simple feature called web-to-case (and there's even email-to-case if for some bizarre reason it'd be easier for you). Your SF admin can enable it, decide which case fields they want to capture and SF generates 2 things:
starts to accept the cases created this way
generates sample html form for you
That form will be stupid. Like braindead stupid. No javascript (well, you can put recaptcha on it), minimal styling, just a bunch of fields and <form> that does POST to certain url. It'll show <select>s and stuff (of course if you add new picklist values or new records to a field that's actually a lookup on the case - you should regenerate the html, there's no magic). It's good for quick & dirty injecting into other page's code and calling it a day.
<form action="https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" method="POST">
<input type=hidden name="orgid" value="00D...redacted">
<input type=hidden name="retURL" value="http://example.com">
<label for="name">Contact Name</label><input id="name" maxlength="80" name="name" size="20" type="text" /><br>
<label for="email">Email</label><input id="email" maxlength="80" name="email" size="20" type="text" /><br>
<label for="phone">Phone</label><input id="phone" maxlength="40" name="phone" size="20" type="text" /><br>
<label for="subject">Subject</label><input id="subject" maxlength="80" name="subject" size="20" type="text" /><br>
<label for="description">Description</label><textarea name="description"></textarea><br>
<input type="hidden" id="external" name="external" value="1" /><br>
<input type="submit" name="submit">
</form>
A developer can reverse engineer a regular POST call out of that form.
And you should. As you can see I've redacted my org's ID. Spamer could use it to send you a lot of messages that way and exhaust your storage usage for example. So ideal solution would do your UI however you want, with captcha if needed, pass data to server, then your server side would make POST call to Salesforce, with org id being secret. (org id for production is very unlikely to change but if you use SF sandbox and later refresh it - it'll get new id, you'll need to update your integration)
It's bit naive but it works. If you need more (for example Case+attachments) you will have to put more leg work, make proper integration that logins to SF, maybe even runs some "describe" calls to dynamically fetch fields/picklist values/lookup records to generate the form. What's your poison, SOAP (old but you'd "consume" the WSDL file and work with classes, objects in your language) or REST...
Check out my other answers (shameless plug)
How to include attachments when cases are submitted via web-to-case to web-to-lead scenarios?
Integrate salesforce and backendless (PHP but same idea)
Machform integration with Salesforce (again PHP and web-to-lead which is similar feature but there's some good philosophical ranting in it)

How to capture current dynamic output of JSP and email it?

In my webapplication, a JSP page outputs to the webpage, the list of users logged in that day. I want to mail the same output to specifics mail-ids. What all Struts2 tags do I need to use?
Grab the HTML using JavaScript and send it as request parameter.
<div id="content">
... (here you should put content which you'd like to mail)
</div>
<form action="mail" method="post" onsubmit="html.value = encodeURIComponent(document.getElementById('content').innerHTML)">
<input type="hidden" name="html" />
<input type="submit" value="Mail this document" />
</form>
It'll be available as request parameter with name "html" in Struts2/Servlet side. The emailing job can be done with help of JavaMail.

PHPSESSID appears in form arbitrarily

I have a login form written in PHP and each time I start the browser and go to the respective page, the first field of the form is this:
<input type="hidden" name="PHPSESSID" value="session_id_code" />
If I close the window, but I don't restart the browser, this doesn't happen. Any idea what's happening and why?
Thanks!
Form's code:
<?php
if (condition) {
?>
<form method="post" action="">
<dl>
<dt>Email:</dt>
<dd><input type="text" name="useremail" /></dd>
<dt>Password:</dt>
<dd>
<input type="password" name="userpass" /></dd>
<dt class="dt-buttons"><input type="submit" name="button_login" value="Login" class="button" /></dt>
</dl>
<input type="hidden" name="formkey" id="formkey" value="224ca00155w2fcda8906e1e40af03a71" />
</form>
<?php
}
?>
The form is simple HTML and is not dynamically generated.
EDIT2:
As I was saying, when I access the page for the first time after I started the browser, this thing happens. If I refresh the page afterwards, the hidden field doesn't show up.
Is it possible to have something to do with the SSL certificate? And if yes, why some pages/forms behave like this and some don't?
Sounds like you've got trans_sid enabled (transparent session id). Using trans_sid can be a security issue, especially if your site links to external content, or you allow link sharing - it lets a user's session ID leak out as part of the URL, meaning the session is highly vulnerable to hijacking.

Checking multiple forms for submission on the same page in coldfusion

Hello again stackoverflow...
Once again I have a troublesome problem. I have a page where I am using jQuery tabs to divide up three update forms. (Two really, one is a cfgrid so it doesn't really count.) Basically, when you submit the first form tab it is fine. However, if you submit the last form, it submits and refreshes the page but nothing was updated.
I've determined it has something to do with identifying which form is being submitted.
Note: These forms are being submitted to same page they are on so I am using this method:
<cfif isdefined("form.submit")>
//database stuff etc
</cfif>
I am submitting the forms by doing this at the end:
<input type="submit" name="submit" id="button" value="Save Changes" onclick = "form.submit()" />
After determining it had something to with identifying which form is being submitted, I changed the button to be:
<input type="submit" name="submit" id="button" value="Save Changes" onclick = "document.forms["form3"].submit()" />
I'm not sure if this is the most efficient way to do this...and I'm not sure how to specific that form3 is being submitted in the coldfusion part...I tried:
<cfif isdefined("form3.submit")>
but this doesn't work. It does not follow through the code.
Note: I'm using coldfusion 8. Also, using CFAJAX tags are limited because our ITS department didn't set up coldfusion correctly on the server...and they don't believe me. Thus I'm kind forced to do it in this ...weird way. It only support cfgrid for some weird reason...
ColdFusion (nor any server-side language) does not know what ID your forms might have - it only knows what you submitted via input (and select/textarea/etc) fields, and puts it in the form scope.
To do what you want, you need to have forms somthing along the lines of:
<form>
....
<input type="submit" name="submit1" value="Save Changes"/>
</form>
<form>
....
<input type="submit" name="submit3" value="Save Changes"/>
</form>
Then on the CF side you check which form it is with:
<cfif StructKeyExists(Form,'Submit1')>
...
</cfif>
or
<cfif StructKeyExists(Form,'Submit3')>
...
</cfif>
Hah, I figured it out! You have to make the submit names different on each form.
<input type="submit" name="submitDoc" id="button" value="Save Changes" onclick = "document.forms["form3"].submit()" />
I just changed the submit name to submitDoc
<cfif isdefined("form.submitDoc")>
Works!

Why is JBoss Post Form sending parameters in URL?

Our JBoss form is posting the parameters in the URL instead of in the request despite being a POST form. I have confirmed that the form is post in the actual page using Firebug. Note that this is within a portlet.
We are submitting the form using javascript like:
function submitForm(action, time)
{
document.getElementById("pageActionInputID").value = time;
document.getElementById("timeSpanFormInputID").value = action;
document.getElementById("formID").submit();
}
<form action="<portlet:actionURL></portlet:actionURL>" method="POST" id="formID">
<input type="hidden" name="pageAction" id="pageActionInputID" />
<input type="hidden" name="timeSpan" id="timeSpanFormInputID" />
</form>
where 'portlet' is from
<%# taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
Any ideas why we are getting the inputs in the URL?
Here is what the resulting markup looks like:
<form id="formID" method="post" action="/portal/auth/portal/myTab?action=1">
<input id="pageActionInputID" type="hidden" name="pageAction"/>
<input id="timeSpanFormInputID" type="hidden" name="timeSpan"/>
</form>
Though it would be great if someone could confirm it. I think the JBoss Portlet throws out post/get and uses action URLs instead.
A descriptive article about render and action URLs