开发者

Struts2 validation when using divs loaded from ajax

开发者 https://www.devze.com 2023-03-03 10:37 出处:网络
We have a Struts2 application using the <sx:tabbedpanel>.I know this has since been deprecated, but we have not yet had time to replace it.

We have a Struts2 application using the <sx:tabbedpanel>. I know this has since been deprecated, but we have not yet had time to replace it.

We're populating the tabs by using the <sx:div> tag and specifying the href attribute, which makes an asynchronous call to the server to populate the contents of the tab. The downside to this is that we lose validation information like <s:actionerror>.

Here's what we think is happening... when the user performs an invalid action, the action class returns validation errors. When the resulting jsp is loaded, the validation m开发者_运维问答essages are available. However, the <sx:div> then makes the asynchronous call back to the server to reload the contents. This time, the action class is just loading data to display, so it doesn't generate any validation messages. The results of this ajax call are then displayed in the browser, without any validation messages.

I've seen many examples on the web of using the <sx:div> tag this way within the tabbedpanel, so I'm guessing this is a problem that has been solved before, we just haven't found it.

Does anyone know of tutorials or examples that show how to do validation in this case?

Thanks for the help, I really appreciate it.


Would it make sense to put the errors outside of the tabbedpanel like:

<s:fielderror />
<sx:tabbedpanel...>
...
</sx:tabbedpanel>

Perhaps we can assist you a bit more if you can post some sample code or provide more info as to what kind of errors are expected and what the content of the tabbed panel is.


We found that we could populate the divs by using the <s:action> tag instead. This gets rendered at the time of the initial request, it does not make an ajax call later. Therefore, the JSPs have access to the validation messages and errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消