labelstruts2struts-tags

How to disable the label for <s:textfield> tag in Struts 2


I have the following tag in Struts 2:

<s:textfield type="text" key="maquina" label="" labelSeparator="" style="width:100;"/>

and I want to disable the label by this tag, in this moment, my JSP code is shown as below:

   <table>
        <thead>
        <tr>

            <th>Hora</th>
            <th>Ruta</th>
            <th>Maquina</th>


        </tr>
        </thead>

        <tbody>
        <%int i=10;%>
        <s:iterator value="datosPlan" var="datosPlanLoading" status="valorDatosPlan">

            <%--//cambia de color la fila en la que se encuentra le cursor--%>
            <tr id="<%=i%>"
                    <%
                        if(i%2 == 0)
                        {
                    %>
                class="alt"
                style="background: #E1EEf4;color: #00557F;"
                onmouseover="destacarFila(this.id);"
                onmouseout="colorOriginalFila(this.id,0);"
                    <%
                    }
                    else
                    {   %>
                onmouseover="destacarFila(this.id);"
                onmouseout="colorOriginalFila(this.id,1);"
                    <%
                        }
                        i++;
                    %>
                    >
                <%--<input type="hidden" id="<%="editar"%>${listaHorariosLoading.codigoHorario}" value="${listaHorariosLoading.nombreHorario}">--%>

                 <td>
                    <p>
                        <s:property value="hora"/>
                    </p>
                </td>
                <td>
                    <p>
                        <s:property value="ruta"/>
                    </p>
                </td>
                <td>
                    <p>
                       <s:textfield type="text" name="maquina" style="width:100;"/>
                    </p>
                </td>

            </tr>

        </s:iterator>
        </tbody>

therefore, I want to disable the label, because I want to have just the <input> tag.


Solution

  • If you use key="maquina" then it will generate label for you.

    If you use label="" then it will generate label for you.

    Don't use key and also do not use label attributes.

    Try this

     <s:textfield type="text" id="maquina" name="maquina" style="width:20;" />
    

    Output:

     <input id="maquina" type="text" style="width:20;" value="" name="maquina">
     </input>
    

    EDIT :

    <td class="tdLabel"></td> will be generated if you use <s:form>

    Try to use html form tag <form> instead of <s:form>.

    For Example

     <form action="someAction" method="get" >
      <s:textfield type="text" id="maquina" name="maquina" style="width:20;" />
     </form>
    

    Note:

    And if you want to use tag then you need to implement either template in freemarker or custom theme.

    Tutorial 1
    Tutorial 2

    In struts.xml

     <constant name="struts.ui.theme" value="simple"/>
    

    will also remove default template.