Instead of using a Link in guidewire I want to use a button to kick off a URL using POST.. example:
<form name="input" method="Post" id="aerForm" name="aerForm" action="https://geico.com">
<input type="hidden" name="rs:command" id="rs:command" value="test"/>
<input type="hidden" name="rs:Format" id="rs:Format" value="PDF"/>
<input type="hidden" name="rc:Toolbar" id="rc:Toolbar" value="false"/>
<input type="submit" value="Get your total">
</form>
I am not sure how to use this in studio or if there is a different way to achieve this. Does anyone have experience with this?
You can use javascript to do that.
function createFormAndSubmit(formTxt)
{
formTxt = formTxt.split("<").join("<");
formTxt = formTxt.split(">").join(">");
formTxt = formTxt.split("'post'>").join("'post' >");
var parser = new DOMParser();
var formElement = parser.parseFromString(formTxt,"text/xml").documentElement;
var newForm = document.createElement('FORM');
newForm.name = 'NewForm';
newForm.method = 'POST';
newForm.action = formElement.getAttribute("action");
newForm.target = 'NewFormTab';
newForm.style.display = "none";
for(var i = 0; i < formElement.childNodes.length; i++) {
var node = formElement.childNodes[i];
var name = node.getAttribute("name");
var value = node.getAttribute("value");
if (name == "null") {
continue;
}
var inputbox = document.createElement('INPUT');
inputbox.type = 'HIDDEN';
inputbox.name = name;
inputbox.value = value;
newForm.appendChild(inputbox);
}
document.body.appendChild(newForm);
newForm.submit();
}
<TemplatePanel><![CDATA[<script>function callMyForm() {createFormAndSubmit("${new organization.package.MyClass().getFormString(policyPeriod)}")}</script>]]></TemplatePanel>
<ButtonInput action="javascript:callMyForm()" id="MyFormButton" value="displaykey.MyFormButtonLabel"/>