You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "M. Onur Tokan" <ot...@gmail.com> on 2004/10/07 11:24:56 UTC

html:link parameter passing

hi,

I have a arraylist of BolgeDTO in request scope. I am iterating this
arraylist in the code below. The problem is I want to add a "edit"
button on the column. And I want to pass the whole properties to the
next form so The form will contain the data from the selected row. I
look at the html:link doc. It says that:


"If you prefer to specify a java.util.Map that contains all of the
request parameters to be added to the hyperlink, use one of the
following techniques:Specify only the name attribute - The named JSP
bean (optionally scoped by the value of the scope attribute) must
identify a java.util.Map containing the parameters."


I tried this method by adding a Map property to the DTO and set it
from its constructor. But it didn't work. Any suggestions please?

<logic:iterate id="b" name="bolgeler">
	<tr>
		<td>
			<bean:write name="b" property="bolge"/>
		</td>
		<td>
			<bean:write name="b" property="bolge_kodu_s"/>
		</td>
		<td>
			<bean:write name="b" property="bolge_kodu_t"/>
		</td>
		<td>
			<bean:write name="b" property="bolge_adi"/>
		</td>
		<td>
			<html:link action="edit"
				name="b">
				Düzenle
			</html:link>
		</td>		
	</tr>
</logic:iterate>
-- 
Regards,
M. Onur Tokan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:link parameter passing

Posted by "M. Onur Tokan" <ot...@gmail.com>.
Ohhh my god! It works. thanks a lot. Do you think it's a good practice?


On Thu, 07 Oct 2004 09:26:50 -0400, Jeff Beal <jb...@webmedx.com> wrote:
> I don't see where 'p' is initialized to a Map in your Java code.
> Somewhere, you need to have Map p = new java.util.HashMap().
> 
> 
> 
> M. Onur Tokan wrote:
> > Sorry for double posting. Jeff It didn't work. It causes Null pointer
> > exception. I hava a bean named BolgeDTO with a property parameters
> > (java.util.Map)
> >
> > And the code is ;
> >
> > ============================
> >                               <html:link page="/edit.do"
> >                                       name="b"
> >                                       property="parameters">
> >                                               Düzenle
> >                               </html:link>
> > ============================
> > while (rs.next())
> >                       {
> >                               Map p=null;
> >                               BolgeDTO bolge = new BolgeDTO();
> >                               bolge.setBolge(rs.getString(1));
> >                               bolge.setBolge_kodu_s(rs.getString(2));
> >                               bolge.setBolge_kodu_t(rs.getString(3));
> >                               bolge.setBolge_adi(rs.getString(4));
> >                               p.put("bolge",rs.getString(1));
> >                               p.put("bolge_adi",rs.getString(4));
> >                               bolge.setParameters(p);
> >                               list.add(bolge);
> >
> >                       }
> >                       if (list.size() > 0)
> >                               request.getSession().setAttribute("bolgeler", list);
> >
> >
> >
> > On Thu, 07 Oct 2004 08:35:37 -0400, Jeff Beal <jb...@webmedx.com> wrote:
> >
> >>For this to work, 'b' would have to be the name of a java.util.Map
> >>object; instead, it is a BolgeDTO.  Use the second method discussed in
> >>the <html:link/> documentation:
> >>
> >>   "Specify both name and property attributes - The specified property
> >>
> >>    getter method will be called on the bean identified by the name (and
> >>    optional scope) attributes, in order to return the java.util.Map
> >>    containing the parameters."
> >>
> >>So, if you created a getMap() method on BolgeDTO, the following would work:
> >>
> >>                          <html:link action="edit"
> >>                                  name="b" property="map">
> >>                                  Düzenle
> >>                          </html:link>
> >>
> >>-- Jeff
> >>
> >>
> >>
> >>M. Onur Tokan wrote:
> >>
> >>>hi,
> >>>
> >>>I have a arraylist of BolgeDTO in request scope. I am iterating this
> >>>arraylist in the code below. The problem is I want to add a "edit"
> >>>button on the column. And I want to pass the whole properties to the
> >>>next form so The form will contain the data from the selected row. I
> >>>look at the html:link doc. It says that:
> >>>
> >>>"If you prefer to specify a java.util.Map that contains all of the
> >>>request parameters to be added to the hyperlink, use one of the
> >>>following techniques:Specify only the name attribute - The named JSP
> >>>bean (optionally scoped by the value of the scope attribute) must
> >>>identify a java.util.Map containing the parameters."
> >>>
> >>>I tried this method by adding a Map property to the DTO and set it
> >>>from its constructor. But it didn't work. Any suggestions please?
> >>>
> >>><logic:iterate id="b" name="bolgeler">
> >>>        <tr>
> >>>                <td>
> >>>                        <bean:write name="b" property="bolge"/>
> >>>                </td>
> >>>                <td>
> >>>                        <bean:write name="b" property="bolge_kodu_s"/>
> >>>                </td>
> >>>                <td>
> >>>                        <bean:write name="b" property="bolge_kodu_t"/>
> >>>                </td>
> >>>                <td>
> >>>                        <bean:write name="b" property="bolge_adi"/>
> >>>                </td>
> >>>                <td>
> >>>                        <html:link action="edit"
> >>>                                name="b">
> >>>                                Düzenle
> >>>                        </html:link>
> >>>                </td>
> >>>        </tr>
> >>></logic:iterate>
> >>>--
> >>>Regards,
> >>>M. Onur Tokan
> >>>
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
Regards,
M. Onur Tokan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:link parameter passing

Posted by Jeff Beal <jb...@webmedx.com>.
I don't see where 'p' is initialized to a Map in your Java code. 
Somewhere, you need to have Map p = new java.util.HashMap().

M. Onur Tokan wrote:
> Sorry for double posting. Jeff It didn't work. It causes Null pointer
> exception. I hava a bean named BolgeDTO with a property parameters
> (java.util.Map)
> 
> And the code is ;
> 
> ============================
> 				<html:link page="/edit.do"
> 					name="b"
> 					property="parameters">
> 						Düzenle
> 				</html:link>
> ============================
> while (rs.next())
> 			{
> 				Map p=null;
> 			 	BolgeDTO bolge = new BolgeDTO();
> 				bolge.setBolge(rs.getString(1));
> 				bolge.setBolge_kodu_s(rs.getString(2));
> 				bolge.setBolge_kodu_t(rs.getString(3));
> 				bolge.setBolge_adi(rs.getString(4));
> 				p.put("bolge",rs.getString(1));
> 				p.put("bolge_adi",rs.getString(4));
> 				bolge.setParameters(p);
> 				list.add(bolge);
> 
> 			}
> 			if (list.size() > 0)
> 				request.getSession().setAttribute("bolgeler", list);
> 	
> 
> 
> On Thu, 07 Oct 2004 08:35:37 -0400, Jeff Beal <jb...@webmedx.com> wrote:
> 
>>For this to work, 'b' would have to be the name of a java.util.Map
>>object; instead, it is a BolgeDTO.  Use the second method discussed in
>>the <html:link/> documentation:
>>
>>   "Specify both name and property attributes - The specified property
>>
>>    getter method will be called on the bean identified by the name (and
>>    optional scope) attributes, in order to return the java.util.Map
>>    containing the parameters."
>>
>>So, if you created a getMap() method on BolgeDTO, the following would work:
>>
>>                          <html:link action="edit"
>>                                  name="b" property="map">
>>                                  Düzenle
>>                          </html:link>
>>
>>-- Jeff
>>
>>
>>
>>M. Onur Tokan wrote:
>>
>>>hi,
>>>
>>>I have a arraylist of BolgeDTO in request scope. I am iterating this
>>>arraylist in the code below. The problem is I want to add a "edit"
>>>button on the column. And I want to pass the whole properties to the
>>>next form so The form will contain the data from the selected row. I
>>>look at the html:link doc. It says that:
>>>
>>>"If you prefer to specify a java.util.Map that contains all of the
>>>request parameters to be added to the hyperlink, use one of the
>>>following techniques:Specify only the name attribute - The named JSP
>>>bean (optionally scoped by the value of the scope attribute) must
>>>identify a java.util.Map containing the parameters."
>>>
>>>I tried this method by adding a Map property to the DTO and set it
>>>from its constructor. But it didn't work. Any suggestions please?
>>>
>>><logic:iterate id="b" name="bolgeler">
>>>        <tr>
>>>                <td>
>>>                        <bean:write name="b" property="bolge"/>
>>>                </td>
>>>                <td>
>>>                        <bean:write name="b" property="bolge_kodu_s"/>
>>>                </td>
>>>                <td>
>>>                        <bean:write name="b" property="bolge_kodu_t"/>
>>>                </td>
>>>                <td>
>>>                        <bean:write name="b" property="bolge_adi"/>
>>>                </td>
>>>                <td>
>>>                        <html:link action="edit"
>>>                                name="b">
>>>                                Düzenle
>>>                        </html:link>
>>>                </td>
>>>        </tr>
>>></logic:iterate>
>>>--
>>>Regards,
>>>M. Onur Tokan
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> 



Re: html:link parameter passing

Posted by "M. Onur Tokan" <ot...@gmail.com>.
Sorry for double posting. Jeff It didn't work. It causes Null pointer
exception. I hava a bean named BolgeDTO with a property parameters
(java.util.Map)

And the code is ;

============================
				<html:link page="/edit.do"
					name="b"
					property="parameters">
						Düzenle
				</html:link>
============================
while (rs.next())
			{
				Map p=null;
			 	BolgeDTO bolge = new BolgeDTO();
				bolge.setBolge(rs.getString(1));
				bolge.setBolge_kodu_s(rs.getString(2));
				bolge.setBolge_kodu_t(rs.getString(3));
				bolge.setBolge_adi(rs.getString(4));
				p.put("bolge",rs.getString(1));
				p.put("bolge_adi",rs.getString(4));
				bolge.setParameters(p);
				list.add(bolge);

			}
			if (list.size() > 0)
				request.getSession().setAttribute("bolgeler", list);
	


On Thu, 07 Oct 2004 08:35:37 -0400, Jeff Beal <jb...@webmedx.com> wrote:
> For this to work, 'b' would have to be the name of a java.util.Map
> object; instead, it is a BolgeDTO.  Use the second method discussed in
> the <html:link/> documentation:
> 
>    "Specify both name and property attributes - The specified property
> 
>     getter method will be called on the bean identified by the name (and
>     optional scope) attributes, in order to return the java.util.Map
>     containing the parameters."
> 
> So, if you created a getMap() method on BolgeDTO, the following would work:
> 
>                           <html:link action="edit"
>                                   name="b" property="map">
>                                   Düzenle
>                           </html:link>
> 
> -- Jeff
> 
> 
> 
> M. Onur Tokan wrote:
> > hi,
> >
> > I have a arraylist of BolgeDTO in request scope. I am iterating this
> > arraylist in the code below. The problem is I want to add a "edit"
> > button on the column. And I want to pass the whole properties to the
> > next form so The form will contain the data from the selected row. I
> > look at the html:link doc. It says that:
> >
> > "If you prefer to specify a java.util.Map that contains all of the
> > request parameters to be added to the hyperlink, use one of the
> > following techniques:Specify only the name attribute - The named JSP
> > bean (optionally scoped by the value of the scope attribute) must
> > identify a java.util.Map containing the parameters."
> >
> > I tried this method by adding a Map property to the DTO and set it
> > from its constructor. But it didn't work. Any suggestions please?
> >
> > <logic:iterate id="b" name="bolgeler">
> >         <tr>
> >                 <td>
> >                         <bean:write name="b" property="bolge"/>
> >                 </td>
> >                 <td>
> >                         <bean:write name="b" property="bolge_kodu_s"/>
> >                 </td>
> >                 <td>
> >                         <bean:write name="b" property="bolge_kodu_t"/>
> >                 </td>
> >                 <td>
> >                         <bean:write name="b" property="bolge_adi"/>
> >                 </td>
> >                 <td>
> >                         <html:link action="edit"
> >                                 name="b">
> >                                 Düzenle
> >                         </html:link>
> >                 </td>
> >         </tr>
> > </logic:iterate>
> > --
> > Regards,
> > M. Onur Tokan
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


-- 
Regards,
M. Onur Tokan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: html:link parameter passing

Posted by Jeff Beal <jb...@webmedx.com>.
For this to work, 'b' would have to be the name of a java.util.Map 
object; instead, it is a BolgeDTO.  Use the second method discussed in 
the <html:link/> documentation:

   "Specify both name and property attributes - The specified property 

    getter method will be called on the bean identified by the name (and
    optional scope) attributes, in order to return the java.util.Map
    containing the parameters."

So, if you created a getMap() method on BolgeDTO, the following would work:

                          <html:link action="edit"
                                  name="b" property="map">
                                  Düzenle
                          </html:link>

-- Jeff

M. Onur Tokan wrote:
> hi,
> 
> I have a arraylist of BolgeDTO in request scope. I am iterating this
> arraylist in the code below. The problem is I want to add a "edit"
> button on the column. And I want to pass the whole properties to the
> next form so The form will contain the data from the selected row. I
> look at the html:link doc. It says that:
> 
> "If you prefer to specify a java.util.Map that contains all of the
> request parameters to be added to the hyperlink, use one of the
> following techniques:Specify only the name attribute - The named JSP
> bean (optionally scoped by the value of the scope attribute) must
> identify a java.util.Map containing the parameters."
> 
> I tried this method by adding a Map property to the DTO and set it
> from its constructor. But it didn't work. Any suggestions please?
> 
> <logic:iterate id="b" name="bolgeler">
>         <tr>
>                 <td>
>                         <bean:write name="b" property="bolge"/>
>                 </td>
>                 <td>
>                         <bean:write name="b" property="bolge_kodu_s"/>
>                 </td>
>                 <td>
>                         <bean:write name="b" property="bolge_kodu_t"/>
>                 </td>
>                 <td>
>                         <bean:write name="b" property="bolge_adi"/>
>                 </td>
>                 <td>
>                         <html:link action="edit"
>                                 name="b">
>                                 Düzenle
>                         </html:link>
>                 </td>
>         </tr>
> </logic:iterate>
> --
> Regards,
> M. Onur Tokan
> 
> 



html:link parameter passing

Posted by "M. Onur Tokan" <ot...@gmail.com>.
hi,

I have a arraylist of BolgeDTO in request scope. I am iterating this
arraylist in the code below. The problem is I want to add a "edit"
button on the column. And I want to pass the whole properties to the
next form so The form will contain the data from the selected row. I
look at the html:link doc. It says that:

"If you prefer to specify a java.util.Map that contains all of the
request parameters to be added to the hyperlink, use one of the
following techniques:Specify only the name attribute - The named JSP
bean (optionally scoped by the value of the scope attribute) must
identify a java.util.Map containing the parameters."

I tried this method by adding a Map property to the DTO and set it
from its constructor. But it didn't work. Any suggestions please?

<logic:iterate id="b" name="bolgeler">
        <tr>
                <td>
                        <bean:write name="b" property="bolge"/>
                </td>
                <td>
                        <bean:write name="b" property="bolge_kodu_s"/>
                </td>
                <td>
                        <bean:write name="b" property="bolge_kodu_t"/>
                </td>
                <td>
                        <bean:write name="b" property="bolge_adi"/>
                </td>
                <td>
                        <html:link action="edit"
                                name="b">
                                Düzenle
                        </html:link>
                </td>
        </tr>
</logic:iterate>
--
Regards,
M. Onur Tokan


-- 
Regards,
M. Onur Tokan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org