top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Struts:multiple form s:fielderror mesg cross over, how to solve?

0 votes
153 views

i need to have multiple on single web page,

(at top panel, our site always provide parts search box/)
(at middle panel, could have other form such as checkout section, login section, etc)

when any single form's validation triggered, then and displayed at all form's textfields place,

how to solve it? or that is struts 2 bug? please help...

posted Jun 19, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes
 
Best answer

Are you setting the field name attribute for your tags?
Could you provide a sample of what you are doing in your jsp?

Another possibility is you need to short circuit your validators.

The official docs cover both these topics:
http://struts.apache.org/release/2.3.x/docs/validation.html#Validation-ShortCircuitingValidator
http://struts.apache.org/release/2.3.x/docs/fielderror.html

Please provide some code samples i can look at to help you more.

answer Jun 19, 2013 by anonymous
Similar Questions
0 votes

In the context of an tag, for instance for a login action, we previously always coded forms as :

 ....

And in the struts.xml we have been using :

content.login
 content.menu
 summary_input
 welcome

This has worked in the past and allowed us to not only use the action="login" to target the execute method of the action, but also to build links to, for instance, login_checkStatus.action to target other, specific methods within the action. I am not sure this Is a common/best practice, I had no prior struts2 experience before joining this company and this is how a lot of the existing functionality is coded. (If this is wrong/there is a better way, please let me know)

Now randomly, this fails to generate the proper action url in the html (it is missing the '.action', which results in a 404 once you post the form)

The only workaround we have found so far is to add the '.action' suffix to the
s:form's action attribute. Before it was always added for us by struts.

So now we are having success with

 ...

I can only assume that this has been affected by the changes related to S2-015 and the wildcard action matching.

+1 vote

I am in the process of upgrading my struts2.3.1.2 application to struts2.3.15.1. Everything works fine except the and tags. In struts2.3.1.2, I have the following code in jsp file

  %{stateName}
  Add 

I used to get correct state name when using struts2.3.1.2. However, using struts2.3.15.1, I am getting the following on web-browser page: %{stateName}

0 votes

I have been using struts quite a long time, but in the last days I have faced a strange behaviour of s:action tag.

In my JSP I am using the tag action to load list to be used to mount my s:select. But in the redered HTML, the result of the action is showing, even when the executeResult is false.

There is something I missing?

JSP code:

struts.xml:

 ^estados[d+].idEstado,
 ^estados[d+].nmEstado

As you can see, in the struts.xml, I have only json result, and I only need as json, but when I use the action tag, I just only need the populated list to be used in the select tag. It is working very well, but the problem is that the json result is showing in the HTML. And it is showing in the top, not in the action tag position, what is strange.

Also, I try to change the struts.devMode to false, but nothing changes.

The project is using struts 2.3.14.3 with rest-plugin. But for this kind ok action, I avoid rest and use just json-plugin.

0 votes

Dear all,Imagine you have the following scenario:

- a property in your action: private Entity entity;
- Entity has a List entity2List
- Entity2 has a Entity3 entity3

Now, you need an s:select with multiple="true" to populate entity3. This corresponds to having a request in the form entity.entity2List[n].entity3.id (n=0,1,2...depending on how many items are selected).

Question: how should the name parameter of the s:select be like to achieve this?

I have tried the following without success (meaning entity.entity2List has is empty):

<s:select multiple="true" name="%{entity.entity2List[].entity3.id}" list="#someList" listKey="id" listValue="code"/>
<s:select multiple="true" name="entity.entity2List[].entity3.id" list="#someList" listKey="id" listValue="code"/>
+2 votes

I can't see what's going on behind the scenes in this example so I'm asking for help in order to understand the Strtus process.

I run the example, leave empty "First Name" to make validation fail, and submit. Then go back to index:

http://localhost:8084/form_xml_validation

and click on edit. But "First name" is reset with the original value. It should be empty because Person instance is managed statically. In fact, other examples (preparable, exclude params) behave as expected, and return an empty String for the filed left empty.

The thing here is than I'm not understanding how Struts works here. I would appreciate if you help me with this.

Example is here:
http://struts.apache.org/release/2.3.x/docs/form-validation-using-xml.html

Code for checkout here:
http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2examples/

Examples doing as expected:
http://struts.apache.org/release/2.3.x/docs/exclude-parameters.html
http://struts.apache.org/release/2.3.x/docs/preparable-interface.html


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...