Mostrando entradas con la etiqueta Struts. Mostrar todas las entradas
Mostrando entradas con la etiqueta Struts. Mostrar todas las entradas

lunes, 21 de mayo de 2007

Array In Struts

<!-- ASI SE ITERA
<logic:iterate indexId="imagesArrayLenght" id="imagesArrayLenghtId" property="offeredProductImages" name="offeredProductForm">
<nested:file property="offeredProductImages[${imagesArrayLenght}]" name="offeredProductForm" styleId="offeredProductImages[${imagesArrayLenght}]"/>
</logic:iterate> -->>


<logic:iterate indexId="currentFieldIndexId" id="currentField" property="reportFields" name="wizardForm">
<tr>
<td class="celdaFormulario" align="right">
<nested:write property="fielNameToShow" name="currentField"/>
</td>
<td class="celdaFormulario" align="left">
<nested:text property="reportFields[${currentFieldIndexId}].fieldValue" name="wizardForm" styleId="${ currentField.fieldName}"/>
<nested:equal value="true" property="requiered" name="currentField">
<font color="red">*</font>
</nested:equal>
<nested:equal value="DateType" property="fieldType" name="currentField"><!-- Mostrar calendar -->
<input type="button" id="btDate<nested:write property="fieldName" name="currentField"/>" value="..." onmousedown="dateChooser('<nested:write property="fieldName" name="currentField"/>','btDate<nested:write property="fieldName" name="currentField"/>');" />
</nested:equal>
</td>
</tr>
</logic:iterate>

Java Web - Suggest tag

Este tag es funciona de la siguiente manera:
Se hace un click en un textfield y va mostrando una lista que se va filtrando con los caracteres ingresados hasta el momento. Lo hace con Ajax.
link: http://struts.application-servers.com/suggest/index.html

Paso 1: crear la clase


import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import fr.improve.struts.taglib.layout.suggest.SuggestAction;

public class CountrySuggestAction extends SuggestAction {

public Collection getSuggestionList(HttpServletRequest in_request, String in_word) {

// Get all the country names
Collection allCountries = CountryCollection.getAllCountries();

// Start to build the suggestions list
ArrayList suggestions = new ArrayList();

if (in_word != null && in_word.length() > 0)
{
Iterator iter = allCountries.iterator();

while(iter.hasNext())
{
String currentWord = (String) iter.next();

if(currentWord.toLowerCase().startsWith(in_word.toLowerCase()))
suggestions.add(currentWord);
}
}

return suggestions;
}

}

Paso 2: configurar la accion de struts


<struts-config>
<action-mappings>
<action path="/getCountrySuggestions"
type="fr.improve.demosuggest.countries.CountrySuggestAction">
</action>
</action-mappings>
</struts-config>


Paso 3: Crear el jsp

<%@ taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %>
<layout:html>
<layout:suggest suggestAction="/getCountrySuggestions" key="Country" styleId="myTextField" value="" suggestCount="8" />
</layout:html>