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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to