1.使用liferay标签生成 验证码的url
<portlet:actionURL
windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>"
var="captchaURL">
<portlet:param name="struts_action" value="/login/captcha" />
</portlet:actionURL>
2.输出验证码(布局自己定义)
<aui:column>
<liferay-ui:captcha url="<%= captchaURL %>" />
</aui:column>
<aui:column>
<a href="#" class="captcha-reload">
<img src="theme/images/refresh.png" alt="Reload-Capcha" />
Sicherheitscode neu laden
</a>
</aui:column>
</aui:layout>
3.刷新js(这里使用jQuery也可以使用AlloyUI)
3.1
jQuery(".captcha-reload").click(function() { jQuery(".captcha").attr("src", jQuery(".captcha").attr("src")+"&force=" + new Date().getMilliseconds()); return false; });
3.2
也可以使用
jQuery(".captcha").attr("src", "<%= captchaURL %>&force=" + new Date().getMilliseconds());
注:建议使用3.1的形式,防止搜索引擎的抓取!
参考(http://www.liferay.com/community/forums/-/message_boards/message/11058781/maximized)
http://www.ibuyincn.com