Solved

Struts html:select java.lang.IllegalArgumentException argument type mismatch

Posted on 2008-10-30
1
4,414 Views
Last Modified: 2013-11-24
Hi,
I am trying to submit a list of 'CustomerDetailsDTO' bean comprising attributes ie. name, address in 'CustomerDetailsForm' using the following code. My form CustomerDetailsForm.getListCustomerDetails() method returns me the list of POJOs of CustomerDetails dto

<html:select name="CustomerDetailsForm" property="listCustomerDetails" onchange="submit()"> <bean:define name="CustomerDetailsForm" property="listCustomerDetails" id="list2" /> <!-- html:optionsCollection value="address" label="address" name="CustomerDetailsForm" property="listCustomerDetails"/--> <html:options collection="list2" property="address" /> </html:select>

Everything goes fine and the page gets loaded but when i click on submit it gives me the exception.
java.lang.IllegalArgumentException: Cannot invoke forms.CustomerDetailsForm.setListCustomerDetails - argument type mismatch at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1778) at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
I experimented the similar thing but there it was String[] as form field. In the above code i need to iterate through the pojo objects stored as elements in list.
I w'ld appreciate if somebody can help.
Thanks in advance
Hh m
0
Comment
Question by:hmeh
1 Comment
 

Accepted Solution

by:
hmeh earned 0 total points
ID: 22857680
Hi,
I have got the solution to the above problem,but wonder that the pojo object's fields must be of String type to work correctly if not using any other custom tag.

The modified code is :

thanks
<html:form action="/getAllSourceTableNames">

	<script>

		function handleEvent(elem){

			alert(' text ' + elem.options[elem.selectedIndex].text);

			document.getElementById("selectedRecord").value = elem.options[elem.selectedIndex].text ;

			document.forms[0].submit();

		}

	</script>
 

	<logic:empty name="ClientTableDetailsForm" property="sourceTableList">

		No Records Found !

	</logic:empty>

	

	<bean:define id="preSelectedRecord" name="ClientTableDetailsForm" property="selectedRecord" type="String"/>

	<br>

	<logic:notEmpty id="stl" name="ClientTableDetailsForm" property="sourceTableList">

		<%= "Length is greater than zero" %>

		<p/>

		<html:select name="ClientTableDetailsForm" property="sourceTableList" value='<%= preSelectedRecord %>' onchange="handleEvent(this)">

		<br>

			<bean:define id="sourceTableList1" name="ClientTableDetailsForm" property="sourceTableList"/>

			<br>

			<html:option value="select">Select </html:option>	

			<br>

			<html:options name="sourceTableList1"/>

			<br>

		</html:select>

		<br>

		<html:hidden name="ClientTableDetailsForm" property="selectedRecord" id="selectedRecord"/>

		<br>
 

	</logic:notEmpty >

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
copyEndy  challenge 15 85
bigHeights  challenge 13 60
maven java path setting 5 59
JUnit 4 @Before and @BeforeClass differences 3 48
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now