Forms not supported in AMP - java

I have search functionality with form. Use method="post" but its not working gives "amp" error that invalid attribute "action".
I have also tried "action-xhr" but still its not working. Please if anyone has solution let me know.
This is my code:
<form method="post" action-xhr="<?php echo base_url(); ?>Search">
<div class="input-group col-md-5 col-xs-6">
<input type="text" name="proname" class="form-control input-lg" placeholder="Find Courses..." />
<span class="input-group-btn">
<button type="submit" class="btn btn-info btn-lg searchBtnBorder"> <i class="glyphicon glyphicon-search"></i> </button>
</span>
</div>
</form>
Thanks,

Are you using https in your action link? AMP forms must all be https
So you will need to use a full path and have SSL Cert installed
https://www.ampproject.org/docs/reference/components/amp-form
"Action must be provided, https"
If you use method "GET" you don't need to use https. Also, you must have target set to "_top" or "_blank" otherwise you won't validate.

Related

No action attribute in html form for Jsoup login

I'm trying to login a website (vimla.se) using Jsoup in android. I'm aware that when submitting forms in html, action is the attribute which we use to POST the login credentials using Jsoup (as explained here). However, in my case, there's no action pointer and the html form looks something like this:
<form id="loginForm" name="loginForm" ng-submit="login()" method="POST">
<input type="email" id="username" form-filler required="required" class="text txtEmail" name="username" placeholder="E-mail" autofocus="autofocus" ng-model="username" />
<br />
<input type="password" id="password" required="required" class="text txtPass" name="password" form-filler placeholder="Password" autofocus="autofocus" ng-model="password" />
<br />
<button type="submit" class="btn" ng-disabled="sending">Login</button>
</form>
So my question is, how do we login such forms using Jsoup?
This is actually a form using Angular.js. The action - attribute is not specified, but ng-submit https://docs.angularjs.org/api/ng/directive/ngSubmit
describes what to do on submit. The LoginController then implements the function that gets executed. Its implementation is hidden in https://vimla.se/scripts/all.min.js?v=1.0.0.0.
a.login=function(){a.sending||(a.sending=!0,a.error=!1,b.post("/user/login",{username:a.username,password:a.password,referer:a.referer})
So the url that gets called is /user/login and the parameters transmitted are username, password, referer

onClick doesn't work when form action is going to jsp page with Apache Shiro

I was originally logging in fine, while needing to submit an onClick method before my form is submitted (as it helps with some of the data sent).
I am now trying to send some of this info to my Java Bean using
<jsp:useBean id="url" class="plan.URL" scope="session"/>
<jsp:setProperty name="url" property="*"/>
The problem I am encountering is that my login is not submitting correctly which seems to mean that when I set
action=""
to
action="viewer.jsp" it isn't calling my onClick method anymore, or at least that's what it seems to be.
Login
<form name="loginform" action="viewer.jsp" method="POST" accept-charset="UTF-8" role="form">
<fieldset>
<div class="form-group">
<input class="form-control" id="user" placeholder="User Name" name="user" type="text">
</div>
<div>
<input class="form-control" placeholder="Password" name="password" type="password" value="">
</div>
<input class="btn btn-lg btn-primary btn-block" type="submit" value="Login" onClick = "login()" >
</fieldset>
</form>
Any advice?
Thanks!
EDIT: I realized that for some reason I wasn't being logged in at all once I put an action. I am using Apache Shiro so I am wondering what's going on with the Authentication.
onclick is conflicting with submit: submit causes the page to reload. onclick might be called but the browser will load the action page at the same time.
Change input's onclick to form's onsubmit then do your login() stuff and return true from it if you want the form to be finally submitted, or false if you don't validate the data and you want to cancel the submition.
onsubmit is an attribute to the <form> element, so you'd do:
... to submit the form depending on your login() function result (true->submit, false->don't submit):
<form onsubmit="return login()" .........>
... to execute login() function and ALWAYS submit afterwards, you can also do:
<form onsubmit="login();return true;" .........>
and just
<input type="submit" ...>
without any event.

Pass parameters to url in jsp

Is this right way to send parameter along with url in jsp page ?
<a href="CancelRequest?userid=<%=idperson%>&userrnamee=<%=namee%>" onclick="return confirm('Are you sure you want to cancel the request?');">
<input type="submit" value="CANCEL REQUEST"></input>
</a>
I tried this But its not taking up the namee field .Please help
sample code:
<input type="button" value="ADDUSER" class="button"
onclick="location.href='UserController?action=insert'"/></p>
<input type="button" value="BACK" class="button"
onclick="location.href='employeeCategory.jsp'" />

How To Debug HTTP Error 400 in JSP

I have the following code that prints some links on the page, and is supposed to call a controller method (launch), upon clicking the image. However, I am getting an Error 400 when I click the button. The generated links look correct to me. The code is in the 1st block. The actual View-Source is in the 2nd.
Unfortunately, I am not getting any errors in my server logs, so I don't know where to begin to debug this.
Does anyone see anything wrong with my code.
<div id="links">
<ul>
<c:forEach items="${listAppURLForm}" var="appURLForm">
<li>
<h2>${appURLForm.link}</h2>
<p>
<span>
<form method="post" action='<c:url value="launch"/>'>
<input type="hidden" name="id" value="${appURLForm.link}"/>
<input type="image" src='<c:url value="/images/rocket-thumbnail.png"/>'/>
</form>
</span>
</p>
</li>
</c:forEach>
</ul>
</div>
The rendered page:
<form method="post" action='launch;jsessionid=40d63cd386e5d01ef8c6dc1c1b76'>
<input type="hidden" name="id" value="http://www.cnn.com"/>
<input type="image" src='/services/images/rocket-thumbnail.png;jsessionid=40d63cd386e5d01ef8c6dc1c1b76'/>
</form>
400 means server cant understand what browser sent
your action='launch;jsessionid=40d63cd386e5d01ef8c6dc1c1b76' might be ?launch;jsessionid=40d63cd386e5d01ef8c6dc1c1b76
<form method="post" action='?launch;jsessionid=40d63cd386e5d01ef8c6dc1c1b76'>
<input type="hidden" name="id" value="http://www.cnn.com"/>
<input type="image" src='/services/images/rocket-thumbnail.png;jsessionid=40d63cd386e5d01ef8c6dc1c1b76'/>
</form>

Upgrading to Tapestry5.1 Javascript Error

Iam upgrading my app from Tapestry 5.0.18 to 5.1.0.5 and i get following javascript error. I know there was a fix for WaitForPage() for partial ajax responses in 5.1.0.5. But i still keep gettin the java script error. Following is my code.
<table t:id="itemPanel" t:type="CustomSlidingPanel" closed="true" subject="literal:itemes" blockId="literal:itemPanel_content" linkToDisplay="New item" actionLink="newitem" zoneOnAction="itemZone"/>
<div id="itemPanel_content" style="display: none;">
<table t:id="itemGrid" t:type="customGrid" source="item" row="itemRow" clientId="literal:itemGrid" rowId="itemRow.itemId" add="edit" include="type, item, price,store,startDate, endDate, ynprimary" inplace="true">
<t:parameter name="editCell">
<t:actionlink t:id="editItem" t:zone="itemZone" t:context="itemRow.id">Edit</t:actionlink>
</t:parameter>
</table>
</div>
<t:zone t:id="itemZone" visible="false">
<t:delegate to="itemBlock" />
</t:zone>
<t:block t:id="itemBlock">
<div id="newitemDiv" class="dataEntry"/>
<div id="itemDivParent">
<div id="itemDiv" class="dataEntry">
<t:form t:id="itemForm" name="itemForm">
<t:if test="itemObject.id">
<script type="text/javascript">insertDivElement('itemGrid${itemObject.id}','itemDivParent','itemDiv','newitemDiv','8');</script>
</t:if>
<t:if test="newitem">
<script type="text/javascript">createNewDivElement('itemDivParent','itemDiv','newitemDiv');</script>
</t:if>
<table t:id="itemComponent" t:type="item" itemObject="itemObject"/>
<div style="width: 50%" align="center">
<input t:id="saveitem" t:type="Submit" class="button" value="Save" /> <input type="button" class="button" value="Cancel" onClick="hideDivs('itemDivParent','itemDiv','newitemDiv');" /> <t:if test="itemImported" negate="true">
<input t:id="deleteitem" t:type="SubmitContext" class="button" value="Delete" t:context="itemObject.id" /> </t:if>
</div>
<br />
</t:form>
</div>
</div>
</t:block>
Here is the error message that i get. Looks like something wrong with "Tapestry.waitForPage(event)" which is in Tapestry.js. Can some one help?
Message: Object doesn't support this property or method
Line: 197
Char: 1
Code: 0
URI: http://localhost:8080/ItemEntry?itemId=131686
<a id="editItemPrice" onclick="javascript:Tapestry.waitForPage(event);" href="itementry.edititemprice/6578">Edit</a>
I believe this might be related to the combine scripts setting as discussed on the mailing list. Set -Dtapestry.combine-scripts=false as a VM argument or add this to your AppModule:
public static void contributeApplicationDefaults(final MappedConfiguration<String, String> configuration) {
configuration.add(SymbolConstants.COMBINE_SCRIPTS, "false");
}
Do you have a reason for not upgrading to 5.3 though? It has a bunch of improvements over 5.1.

Categories