You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by red phoenix <ro...@gmail.com> on 2006/12/19 02:46:20 UTC

in struts2

I want to change my code from struts1 to struts2,I use displaytag and
<bean:write> to show following code,it can run well,<bean:write
name="element" property="ID"/> will show 1,2,....
<%@ taglib uri="/struts-tags" prefix="s" %>
<display:table name="testList" export="false" sort="external"
defaultsort="1" pagesize="2" id="element" size="rsize"
requestURI="/test.do">
<display:column title="choice">
<input type="checkbox" id="c1" name="id1" value=<bean:write name="element"
property="ID"/>>
</display:column>

I know struts2 will use <s:checkbox> and use <ww:property value="id" /> to
replace <bean:write name="element" property="ID"/>,so I modify code like
follows:
<%@ taglib uri="/struts-tags" prefix="s" %>
<display:table name="testList" export="false" sort="external"
defaultsort="1" pagesize="2" id="element" size="rsize"
requestURI="/test.do">
<display:column title="choice">
<s:checkbox name="id" fieldValue=<ww:property value="id" />/>
</display:column>

But when I run it,I find <ww:property value="id" /> don't make any
function,checkbox's value is still <ww:property value="id" /> and not the
real value "1,2,3...."
I am puzzled with struts2,because there is not a learning book about
struts2,the struts2 document is very brief,not detail!
Anybody could give me a detail method to resovle my above question?

Thanks in advance
Best regards,
Rod

Re: in struts2

Posted by Laurie Harper <la...@holoweb.net>.
red phoenix wrote:
> I want to change my code from struts1 to struts2,I use displaytag and
> <bean:write> to show following code,it can run well,<bean:write
> name="element" property="ID"/> will show 1,2,....
> <%@ taglib uri="/struts-tags" prefix="s" %>
> <display:table name="testList" export="false" sort="external"
> defaultsort="1" pagesize="2" id="element" size="rsize"
> requestURI="/test.do">
> <display:column title="choice">
> <input type="checkbox" id="c1" name="id1" value=<bean:write name="element"
> property="ID"/>>
> </display:column>
> 
> I know struts2 will use <s:checkbox> and use <ww:property value="id" /> to
> replace <bean:write name="element" property="ID"/>,so I modify code like
> follows:
> <%@ taglib uri="/struts-tags" prefix="s" %>
> <display:table name="testList" export="false" sort="external"
> defaultsort="1" pagesize="2" id="element" size="rsize"
> requestURI="/test.do">
> <display:column title="choice">
> <s:checkbox name="id" fieldValue=<ww:property value="id" />/>
> </display:column>

Two problems here: First, 'ww:property' should be 's:property', as 
specified by your taglib declaration. Second, you can't use a JSP custom 
tag as an attribute value within another custom tag; JSP tags don't nest 
like this, it's illegal syntax.

Try something like

   <s:set id="idField" value="%{id}"/>
   <s:checkbox name="id" fieldValue="%{idField}"/>

That might not be quite right, but the point is you need to seperate the 
two tag invocations.

> But when I run it,I find <ww:property value="id" /> don't make any
> function,checkbox's value is still <ww:property value="id" /> and not the
> real value "1,2,3...."
> I am puzzled with struts2,because there is not a learning book about
> struts2,the struts2 document is very brief,not detail!
> Anybody could give me a detail method to resovle my above question?

There's no book specifically on Struts2 yet, but since Struts2 is based 
on Webwork, the Webwork In Action book is a good reference.

I'm not sure which 'struts2 document' you're referring to, but there's a 
great deal of documentation, tutorials, guides, sample application and 
reference documentation on the Struts2 website and wiki.

HTH,

L.


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


Re: in struts2

Posted by Antonio Petrelli <ap...@apache.org>.
red phoenix ha scritto:
> I want to change my code from struts1 to struts2,I use displaytag and
> <bean:write> to show following code,it can run well,<bean:write
> name="element" property="ID"/> will show 1,2,....

I think it is better wo use JSTL <c:out> tag:
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/out.html

Ciao
Antonio


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