You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hudayioglu, Fehmi" <Fe...@Dresdner-Bank.com> on 2001/12/12 09:35:33 UTC

AW: Newbie Question: dynamically setting value in a struts link tag / also dynamically placing value from a JavaBean Collection into a S truts Form attribute.

hi, if you are using struts 1.0, there is no way to create links (or
checkboxes... )dynamically, unless you use nightly builds or wait for the
struts 1.1 (as far as I know).
I had the same problem with struts 1.0 and my solution was like this. though
I have still some doubts on this solution.

in JSP.
<logic:iterate id="Roll" name="UserAdminFormBean" property="listrowheader"
indexId="index" offset="0">	
	<INPUT type='text' name='Header[<bean:write name="index"/>].name'
value='<bean:write name="Roll" property="name" />' />
</logic:iterate>

in Action Bean I have used
while(true)             //Build header list
{
    String headername = request.getParameter("Header[" + i + "].name");
    if(headername==null) //if there is no more row, exit the while loop.
        break;
    Roll newHeader=new Roll(headername);
    tempHeaders.add(newHeader);
    i++;
}

So, this mechanism simply skips struts. Sure there may be better
solutions.(though i don't want to rewrite my existing code:)
hope it answers some of your questions. bye.


-----Ursprüngliche Nachricht-----
Von: Campbell, Sheri [mailto:Sheri.Campbell@SPR.DOE.GOV]
Gesendet am: Tuesday, December 11, 2001 5:03 PM
An: 'struts-user@jakarta.apache.org'
Betreff: Newbie Question: dynamically setting value in a struts link tag
/ also dynamically placing value from a JavaBean Collection into a
Struts Form attribute.


I've got a Struts Action class that calls a method on a JavaBean which
performs a SQL and puts resultSet into a Collection.  

In my .jsp page I am going through the Collection on my JavaBean and using
<strutsbean:write name="pvb" property="empid"/> to display the values into a
html table.

I am trying to also add a strutshtml:link  which contains a value=
(employeeid="empid") where I want its value to be built dynamically from the
Collections value:

<strutshtml:link href="assessment.do?employeeid=empid"> 

How do I do this?    Better yet, I have the employeeid in my javaBean's
Collection.  How do I get that value from the Collection into the .jsp's
associated StrutsActionForm's employeeid value? 


This is what I've got right now in my .jsp, the value is "empid" on my
action class not the actual value:

<strutshtml:form action="assessment.do" name="employeeForm"
type="com.proverb.EmployeeForm">
<strutslogic:iterate name="EmployeeCollection" id="pvb" >
<tr>
<td>
  <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <strutshtml:link href="assessment.do?employeeid=empid"> 
    <strutsbean:write name="pvb" property="empid"/>
    </strutshtml:link>
  </font>
   &nbsp;
</td>
<td>
  <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <strutsbean:write name="pvb" property="lname"/>
   </font>
   &nbsp;
</td>
<td>
  <font face="Verdana, Arial, Helvetica, sans-serif" size="2">
    <strutsbean:write name="pvb" property="fname" />
  </font>
   &nbsp;
</td>
 
</strutslogic:iterate>
</strutshtml:form>
 

Thanks!!!!!







--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>