Search code examples
javascripthtmldomstruts

html: text and createElement


i have difficulty understanding the below code snippet. I am trying to understand where the value attribute is assigned to, however i only see the property attribute.

 <html:text indexed="true" name="<%=(String)
 currentItr.next()%>" property="<%=(String) currentItr.next()%>"/>

because i am slightly more familiar with HTML DOM, i was able to create the element i want using below:

    object<%=i%> = document.createElement('
<input type="text" name="<%=name%>' + '[' + 
sectionId + '].mySpecialList[' + row[id] + '].
<%=curProp%>" id=' + sectionId + 
'size="<%=curItr.next()%>" value="<%=curItr.next()%>">');

which i know i can grab and access using the following:

var obj = document.forms["myForm"].elements["mySpecialList[0].mySmallList[0].someProperty"];

what is the html:struts equivalent of the createElement bit? Because when i use the html:text code snippet, i am unable retrieve or parse the value attribute.

for example: the <html:text> tag seems to automatically create an element with name, value and size. however, when i try to access the same element in javascript, i get the element's column name instead, and not the value


Solution

  • It's unreadable and you should not use scriptlets, use JSTL for that.

    <html:text property="propertyNameOfYourBean"/>
    

    For list you should use <c:forEach> tag.