留言板
Button as link and submitter
Excuse me please to post again a problem, but then I will be done with my UI and with alloy it already looks great
I want a button as a link and as a submitter of a value to a method in my MVCPortlet class.
The link is inside a java array.
The attribute that is passed to the java method is inside a input field.
It works if I do just one of this two (for both).
I tried to combine them but it doesn't work.
I tried this:
It calls the method but it doesnt opens a new tab in my browser. In my browser I can see that it is a link, if I click right on it -> new tab, it opens it correctly in a new tab. But not if I just click on the button.
Second way:
It just opens google but doesn't calls the method. Also it seems not possible to get an Java attribute inside of a javascript, but maybe I could get the value out of a hidden input field.
I hope you understand my problem, would be fantastic to get this very good help again,
Sincerely Mr.Jimmy
I want a button as a link and as a submitter of a value to a method in my MVCPortlet class.
The link is inside a java array.
The attribute that is passed to the java method is inside a input field.
It works if I do just one of this two (for both).
I tried to combine them but it doesn't work.
I tried this:
<a href="<%=unread[i][k]%>" target="_blank">
<aui:button type="submit" />
</a>
It calls the method but it doesnt opens a new tab in my browser. In my browser I can see that it is a link, if I click right on it -> new tab, it opens it correctly in a new tab. But not if I just click on the button.
Second way:
<aui:button type="submit" onclick="window.open('http://www.google.de', '_blank', ''); return false;" />
It just opens google but doesn't calls the method. Also it seems not possible to get an Java attribute inside of a javascript, but maybe I could get the value out of a hidden input field.
I hope you understand my problem, would be fantastic to get this very good help again,
Sincerely Mr.Jimmy
Pankaj Kathiriya,修改在9 年前。
RE: Button as link and submitter
Liferay Master 帖子: 722 加入日期: 10-8-5 最近的帖子Mr Jimmy:
Second way:<aui:button type="submit" onclick="window.open('http://www.google.de', '_blank', ''); return false;" />
It just opens google but doesn't calls the method. Also it seems not possible to get an Java attribute inside of a javascript, but maybe I could get the value out of a hidden input field.
In the second way, you mentioned above make changes as below.
<aui:button type="submit" onclick="window.open('http://www.google.de', '_blank', '');" />
Here I removed return false statement which was restricting form to submit .
You can get your java attributes/variables inside javascript using EL or scriptlet.
In your case it would be like window.open('<%=unread[k]%>', '_blank', '');
Pankaj Kathiriya:
Here I removed return false statement which was restricting form to submit
absolutely right!
Pankaj Kathiriya:
In your case it would be like window.open('<%=unread%>', '_blank', '');That hasn't worked for me with
window.open('<%=unread[i][k]%>', '_blank', '');
so I used EL and JSTL, that worked:
<c:set var="url" scope="session" value="<%=unread[i][k]%>" />
<aui:button type="submit" onclick="window.open('${url}', '_blank', '');" />
Thank you a lot Pankaj!