I have been trying to debug this application for 2 days now..
I am unable to understand what is wrong wth the code..
Please someone help me out...
I keep on getting this message as the Error 500 and I dont understand what it means while
this is the web.xml file--
Now the welcome.jsp is shown as this file --
The struts-config.xml has the action-mapping. Please consider the action-mapping for the enterDetails since the previous action mapping works fine.
The form-bean UserDetailsForm is also included later in this section
The code for the form-bean is as follows-
The countryData is another set of class which is as follows-
The action-class is as shown--
Joined: Jun 27, 2010
What I fail to understand here is that what should the optionsCollection property have?
the property that points to the list?
the name that points to the CountryData ??
I am really confused when it comes to this..
Please help me out..Thanks..
I guess the formbean is not being populated.
What i see is..
first on loading web.xml -> struts-config.xml -> welcome.jsp -> It is stuck..
If that is resolved, then the action will be loaded right and the bean be populated right???
so the course of action would be to call a test.jsp page from welcome-file list which redirects to the Action mapping.
The action class then calls the populate method and populates the formbean
which then after wards delegates the control to the welcome.jsp which displays the select options tag?
would that work?
Joined: Jun 27, 2010
I finally resolved it--
Here is the solution--
The struts-config.xml file--
The Action-form was created using SelectedItem as one more property for using it in the jsp file.
The Collections element was induced in the request object as CountryList.
The Action - Class
The show-Details.jsp file--
What I observed was this--
For this to work in the form-bean if you have a country-list
countryList.add(new CountryData("1", "USA"));
countryList.add(new CountryData("2", "Canada"));
countryList.add(new CountryData("3", "Mexico"));
Now, since the attribute in the request is set to countryListAttribute,
At the JSP side, for the html:select code,
<html:select name="UserDetailsForm" property="selectedItem">
<!-- property refers to the name of the request parameter in the form -->
<htmlptionsCollection name="countryListAttribute" />
<!-- label="countryName" value="countryId" -->
Here , the action pertains to any action that will get executed once the submit is clicked.
The property=”selectedItem refers to a string property in the form “UserDetailsForm ” which has been mapped in the struts-config.xml as a form-bean mapping.The name of the form-bean is “UserDetailsForm”. Now, with the name=”countryListAttribute” , it is taken from the request scope. The request scope is present in the action mapping as described as under.
Thus an important part to be noted is that in html:select , the property=”selectedItem” should be a string in the form-bean.
If you do not have getlabel() and getValue() to the associated form-bean then, by default, if you do not put label=”countryName” and value=”countryID” , it searches for the implementation of the getLabel() and getValue() inside the form-bean.