struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger Varley" <roger.var...@googlemail.com>
Subject [S2] Ajax Forms
Date Wed, 09 May 2007 14:27:27 GMT
Hi

Is it possible to insert/update the value of a <s:textfield> tag in a
form using Ajax? I've listed the data entry jsp and the Ajax response
jsp page below. When the form is loaded at start up, I see the text
values and an empty text field from the ajax response. After entering
a value into productCode field, I see the text, the <s:property> value
is displayed, but the <s:textfield> stays empty.

Regards
Roger

<!-- Data Entry jsp -->

<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
    <head>
        <title>Edit Sales Order with Static Form</title>
        <s:head theme="ajax" debug="true"/>
        <script type="text/javascript">
            function filterProductCode(field) {
            return field.name=="orderDetailLine.productCode";
            }
        </script>
    </head>
    <body>
        <s:text name="Account Number"/>
        <s:property value="order.header.accountNumber"/>
        <br>
        <s:text name="Order Number"/>
        <s:property value="order.header.orderNumber"/>
        <br>

                <s:div name="detailLines" cssClass="detailLines">
                    <s:iterator value="order.details" status="status">
                        <s:set name="indexValue" value="#status.index"/>


                        <s:textfield
name="order.details[%{#status.index}].productCode"
value="%{productCode}" theme="simple" disabled="true"/>
                        <s:textfield
name="order.details[%{#status.index}].productDescription"
value="%{productDescription}" theme="simple" disabled="true"/>
                        <s:textfield
name="order.details[%{#status.index}].quantity" value="%{quantity}"
theme="simple" disabled="true"/>
                        <br/>

                    </s:iterator>
                </s:div>
                <s:div name="detailEntry" cssClass="detailEntry">
                    <s:url id="getProductInfoURL" action="ListProductInfo"/>
                    <s:form id="form" method="post" action="EditOrder"
theme="simple">

                    <s:textfield name="orderDetailLine.productCode"
                                 label="productCode"
                                 id="productCode"

onchange="dojo.event.topic.publish('getProductInfoTopic',
this.value);"/>
                    <s:div name="updateDiv" theme="ajax"
                           loadingText="Hang on a sec .... "
                           href="%{getProductInfoURL}"
                           formId="form"
                           listenTopics="getProductInfoTopic"
                           formFilter="filterProductCode">

                     </s:div>


                   <s:textfield name="orderDetailLine.quantity"
value="%{quantity}"/>

                <s:submit/>
                </s:form>
                </s:div>


    </body>

</html>

<!-- Ajax Response JSP -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>

This text should appear in the div<br/>
The following is the property value<br/>
<s:property value="productInfo.productDescription"/>
<s:textfield name="productInfo.productDescription"
value="%{productDescription}"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message