You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Struts2 Fan <st...@gmail.com> on 2007/05/11 09:54:54 UTC

[S2]Dynamic List dissappears when validation fails

Hi all,

I have a <s:select> and <s:submit> in the jsp. When <s:submit> is clicked a
list is put below (<s:textbox> list) according to the value in the
<s:select>. The values in the <s:textboxes> are all have to be not-null so
there is validation for this object. 

Here is the problem, when the validation fails, as expected the action
cannot be reached so the error messages appear but the list is not
displayed. I don't want the list to disappear. Do I have to write an
interceptor that runs before validation or do I have to do something?

Thanks in advance.
-- 
View this message in context: http://www.nabble.com/-S2-Dynamic-List-dissappears-when-validation-fails-tf3726002.html#a10427495
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2]Dynamic List dissappears when validation fails

Posted by Guillaume Carré <gu...@gmail.com>.
2007/5/11, Dave Newton <ne...@yahoo.com>:
> Probably not.
>
> But your original message wasn't really specific
> enough.
>
> What do you mean, "dynamic list"? Ajax? Hidden div?
> How is it populated? How is it made visible?

if he has the same issue that I have, here is what he probably means :-)

ther is an action, that populates a bean with a List of whatever.
On the JSP he has a select form, populated with the List.
He submits, validation fails, and he's forwarded to the input jsp.

His problem is that whateverList is empty in the jsp.
-- 
Guillaume Carré

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


Re: [S2]Dynamic List dissappears when validation fails

Posted by Laurie Harper <la...@holoweb.net>.
You didn't include your struts.xml action mappings so I'm guessing, but 
from the behaviour you describe it sounds like the 'input' result is 
pointing directly to a JSP, rather than to an action that knows how to 
do the data pre-fetch.

L.

Struts2 Fan wrote:
> Ok :) I will try to be more specific. 
> 
> I have a <s:select>, <s:submit>, <s:iterator> on the jsp. When submit is
> clicked, it goes to the action and populates the list and every record in
> the list puts a textbox on the jsp according to the selected <s:select>. 
> 
> When the list is populated the user enters the values in the jsp and presses
> the update button. If all the fields are not-null every thing is ok. The
> values are updated. But when one of the textfields is empty, validation
> fails and gives the proper error message. Because of giving validation
> error, the request cannot go to action so I cannot repopulate the list with
> the entered values. I hope this explaination and codes are enough. 
> 
> --------jsp-------------
> <s:form action="setProperties" method="post">
>     <s:select name="model.id" list="modelList" listKey="id"
> listValue="UIName" theme="simple"/>
>     <s:submit method="setProperties" key="button.select"></s:submit>
> 
>     <s:iterator value="subProperties" id="property" status="stat">
>         <s:textfield name="%{'subProperties['+#stat.index+'].value'}"
> label="${property.propertyType.name}"/>
>     </s:iterator>
>     <s:submit key="button.updateProperties" method="updateProperties"/>
> </s:form>
> </body>
> </html>
> ---------------------------------
> ---------action methods----------
> 
>     public String setProperties() throws Exception{ 
>             setModel(modelManager.get(model.getId()));
>             subProperties = model.getPropertyList();
>              return SUCCESS;
>     }
> 
>     public String updateProperties() throws Exception{
>         for (Property property : subProperties) {
>               // I update the properties with the inputs got from jsp
> 
>             }
>               // assign subProperties again here
>         return SUCCESS;
>     }
> 


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


Re: [S2]Dynamic List dissappears when validation fails

Posted by Struts2 Fan <st...@gmail.com>.
in the prepare() method the value of the <s:select> doesn't exist too. It
gets null value. 

Dave I hope I explained it well this time. 

Thanks anyway.

-- 
View this message in context: http://www.nabble.com/-S2-Dynamic-List-dissappears-when-validation-fails-tf3726002.html#a10435496
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2]Dynamic List dissappears when validation fails

Posted by Struts2 Fan <st...@gmail.com>.
Ok :) I will try to be more specific. 

I have a <s:select>, <s:submit>, <s:iterator> on the jsp. When submit is
clicked, it goes to the action and populates the list and every record in
the list puts a textbox on the jsp according to the selected <s:select>. 

When the list is populated the user enters the values in the jsp and presses
the update button. If all the fields are not-null every thing is ok. The
values are updated. But when one of the textfields is empty, validation
fails and gives the proper error message. Because of giving validation
error, the request cannot go to action so I cannot repopulate the list with
the entered values. I hope this explaination and codes are enough. 

--------jsp-------------
<s:form action="setProperties" method="post">
    <s:select name="model.id" list="modelList" listKey="id"
listValue="UIName" theme="simple"/>
    <s:submit method="setProperties" key="button.select"></s:submit>

    <s:iterator value="subProperties" id="property" status="stat">
        <s:textfield name="%{'subProperties['+#stat.index+'].value'}"
label="${property.propertyType.name}"/>
    </s:iterator>
    <s:submit key="button.updateProperties" method="updateProperties"/>
</s:form>
</body>
</html>
---------------------------------
---------action methods----------

    public String setProperties() throws Exception{ 
            setModel(modelManager.get(model.getId()));
            subProperties = model.getPropertyList();
             return SUCCESS;
    }

    public String updateProperties() throws Exception{
        for (Property property : subProperties) {
              // I update the properties with the inputs got from jsp

            }
              // assign subProperties again here
        return SUCCESS;
    }

-- 
View this message in context: http://www.nabble.com/-S2-Dynamic-List-dissappears-when-validation-fails-tf3726002.html#a10434563
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2]Dynamic List dissappears when validation fails

Posted by Dave Newton <ne...@yahoo.com>.
--- Struts2 Fan <st...@gmail.com> wrote:
> I just wonder it is only me needs this kind of
> dynamic stuff :)

Probably not.

But your original message wasn't really specific
enough.

What do you mean, "dynamic list"? Ajax? Hidden div?
How is it populated? How is it made visible?

d.



       
____________________________________________________________________________________You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_html.html

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


Re: [S2]Dynamic List dissappears when validation fails

Posted by Struts2 Fan <st...@gmail.com>.
I just wonder it is only me needs this kind of dynamic stuff :)
-- 
View this message in context: http://www.nabble.com/-S2-Dynamic-List-dissappears-when-validation-fails-tf3726002.html#a10433917
Sent from the Struts - User mailing list archive at Nabble.com.


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