MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
WGPuckett
Post subject: Struts 2 and <s:radio>  PostPosted: Mar 21, 2011 - 04:58 PM
Registered Member
Registered Member


Joined: Jun 08, 2006
Posts: 78

I 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:
Quote:
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:
Code:
<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
Code:
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:
Code:
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?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-swapna
Post subject: RE: Struts 2 and <s:radio>  PostPosted: Mar 22, 2011 - 09:55 AM



Joined: Nov 11, 2010
Posts: 2499

WGPuckett,

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.

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
WGPuckett
Post subject: RE: Struts 2 and <s:radio>  PostPosted: Mar 22, 2011 - 05:40 PM
Registered Member
Registered Member


Joined: Jun 08, 2006
Posts: 78

That'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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits