- This topic has 2 replies, 2 voices, and was last updated 13 years, 8 months ago by Glenn Puckett.
-
AuthorPosts
-
Glenn PuckettParticipantI have a very specific issue that I just can’t find the right answer to. It’s driving me crazy!!
I have a situation where I need to build a list of options for a user to select from. In my design I think it best to do this with a radio button group. So I have generated a table with one column showing the radio button and other columns containing information about that selection. I have been able to sucessfully generate that table and radio button. However, I am having problems giving the <s:radio> function the proper value for each instance of the button.
I think my question is really about data handling in Struts 2, because I have been able to get the tag to work. I just can’t get the right information to the tag.
I spent the weekend researching this and discovered many different suggestions and have tried most of them. Nothing has changed the result.
No matter what option I try I get the following error:
tag ‘radio’, field ‘list’, name ‘masterKey’: The requested list key ‘#{${current.id}:”}’ could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} – [unknown location]
Here is the latest version of the code in my jsp:
<c:forEach items="${wizmstBean.wizdtlList}" var="current" varStatus="i"> <tr class="${rowclass}"> <td nowrap="nowrap" class="tabletd" align="center"> ${current.id} <s:radio theme="simple" name="detailKey" list="#{1:''}"/> </td> <td nowrap="nowrap" class="tabletd"> ${ current.adminProjClassTbl.name } </td> <td nowrap="nowrap" class="tabletd"> ${current.adminProjTypeTbl.name} </td> <td nowrap="nowrap" class="tabletd"> ${current.adminIndustryTypeTbl.name} </td> </tr> </c:forEach>
This code displays the page just fine other than my problem with the radio button.
Notice what I have put in the list parameter of the s:radio function. Because of the
list="#{1:''}"
I am getting 1 as the value of every radio button. I need to get the proper value in that option. Notice also that I have ${current.id} beside the radio button. This currently displays a value beside the radio button. This is the value that I want to use for the radio button. I have researched for hours, hours and more hours. I have tried both “c:forEach” and “s:iterator”. I can’t get this to work!!!
I know the answer will be embarasingly simple but I need to replace the list paramater with something that will use current.id as the radio value. I have tried NUMEROUS variations based on what I have encountered on the ‘net. All of which results in the error shown above. This includes:
list="#{current.id:''}" list="#{#current.id:''}" list="#{${current.id}:''}" list="#{current.{id}:''}"
What is the code I must use in the list parameter so that the value of current.id is the value of the radio button?
Please!! Help me with this. How do I change the list parm to make this work?
support-swapnaModeratorWGPuckett,
I have attached a sample project that should provide you some background on using the Struts iterator, select and radio tags. In the project, please have a look at the deleteBlogPage.jsp” and “reviewPostsPage.jsp”. The “deleteBlogPage.jsp” makes use of the Struts radio tag.
Please let us know if you need more help.
Attachments:
You must be logged in to view attached files.
Glenn PuckettParticipantThat’s not an anwer. The example you provided is just another cookie cutter example of using struts tags. Those can be found on the internet by the dozens. That’s the problem with tutorials and real world comparisons. Tutorials address the standard easiest use of a subject. Then you get to real world development and you find that the tutorial gave you about 80% of what you need. You have to go out and find the other 20%. That’s not a problem. I don’t mind doing the research. It’s those few topics that no answer seems to be available that causes so much frustration.
I appreciate the effort, but evidently you don’t know the answer any more than I do. Maybe the answer is that there is no answer. I refuse to accept that. But short of someone who actually knows the solution getting interested I have no choice but to try to come up with a different approach. Maybe I’ll just try to build the html manually and forget using the tag for this.
-
AuthorPosts