Question

I use Liferay 6.2 on JBoss 7.1.1. Also I am using a JSP as view with AlloyUI.

I want a button as a link and as a submitter of a value to a method in the 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 use just one of this two. 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 is not possible to get an Java attribute inside of a Javascript, but I could get the value out of a hidden input field. But still there would be the problem that it doesn't call the method.

Was it helpful?

Solution

I decided to get on with the second solution. The first mistake was return false; in my onclick param, so I deleted it. Then the submit function works as usual. The next problem was to access a Java variable inside the javascript onclick method, so I used EL and JSTL to get it work:

<c:set var="url" scope="session" value="<%=unread[i][k]%>"/>
<aui:button type="submit" onclick="window.open('${url}', '_blank', '');" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top