Forums

Home » Alloy UI » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ramya Sree Kalagiri
cannot get aui input value in aui script
December 19, 2012 10:52 PM
Answer

Ramya Sree Kalagiri

Rank: New Member

Posts: 8

Join Date: December 19, 2012

Recent Posts

Hi,
I'm using spring portlet MVC and liferay 6.1 CE. I'm using alloy UI in my jsp page. And the sample code goes like this I merged viewDetails, editDetails and addDetails in a single jsp file.


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib prefix="aui" uri="http://liferay.com/tld/aui" %>
<portlet:defineObjects /><portlet:defineObjects/>
<%boolean disable=false;
%>
<aui:script>
AUI().use('aui-form-base', function(A) {
<%
Object mode=renderRequest.getAttribute("mode");
if(mode!=null && ("editDetail".equals(mode.toString())||"viewDetail".equals(mode.toString())))
{%>

var name = A.one('#name');
name.val("ramya");
<%}
else if(mode!=null && "viewSoilProfile".equals(mode.toString()))
{
disable=true;
}
%>
});
</aui:script>
<aui:form>
name: <aui:input type="text" name="name" id="name" <%if(disable){%>disabled="disabled"<%} %>/>
</aui:form>



I'm stuck with the following problems:
1.I'm getting an exception "org.apache.jasper.JasperException: /html/details.jsp (line: 30, column: 52) Unterminated &lt;aui:input tag
2.if I remove the scriplet from aui:input tag then I'm getting script error that null is null or not an object because "name" retrieved in aui:script is null.



It is working properly if I use normal html form and input without aui prefix

<form>
name: <input type="text" name="name" id="name" <%if(disable){%>disabled="disabled"<%} %>/>
</form>



could anyone please help me in sorting out these 2 problems. Thanks in advance
Amos Fong
RE: cannot get aui input value in aui script
December 20, 2012 5:37 PM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1844

Join Date: October 7, 2008

Recent Posts

Hi,

You cannot put a scriptlet within a tag library like that. You should initialize the variable before the taglib tag. Something like this:

 1<%
 2String disabled = "";
 3
 4if (disable) {
 5    disabled = "disabled";
 6}
 7%>
 8
 9<aui:input type="text" name="name" id="name" disabled="<%= disabled %>" />