You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Omar Ngarigari <ng...@yahoo.com> on 2012/09/24 02:03:51 UTC

s:checkbox inside s:iterator in struts2.3.1.2

Hello,

Please help, I am having problem that I cannot figure out how to solve it. The problem is as follow:

1. JSP page:
<s:iterator value="myList" var="record">
<s:property value="#record.ageNumber"/>
<s:property value="#record.name"/>
<s:checkbox name="stringList" fieldValue="%{age}"/>
</iterator>

2. Action Class
public class ExampleAction extends ActionSupport {
private List<Pojo> myList = new ArrayList<Pojo>();
private List<String> stringList = new ArrayList<String>();
private int age;
getter/setters()

public String execute(){
generatePDFFile(age);
return Action.SUCCESS;
}
}

My problem is I don't know how to get the age in checkbox at JSP page back in the action class to generate PDF file. The PDF file is generated based on the age from the JSP. Is there any one can help me to achieve that.

Thanks,

Omar N.

Re: s:checkbox inside s:iterator in struts2.3.1.2

Posted by Omar Ngarigari <ng...@yahoo.com>.
I figured it out. I think the correct way is to use fieldValue instead of value. It is working now. Thanks so much for your help.

<s:checbox name="age" fieldValue="%{myList.ageNumber}"/>


________________________________
 From: Lukasz Lenart <lu...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org>; Omar Ngarigari <ng...@yahoo.com> 
Sent: Monday, September 24, 2012 2:08 PM
Subject: Re: s:checkbox inside s:iterator in struts2.3.1.2
 
2012/9/24 Omar Ngarigari <ng...@yahoo.com>:
> Hello,
>
> I changed my JSP page as per the documentation recommendation:
>
> <s:iterator value="myList" var="record">
> <s:property value="#record.ageNumber"/>
> <s:property value="#record.name"/>
> <s:checkbox name="age" value="%{#record.ageNumber}"/>
> </iterator>

And works ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Re: s:checkbox inside s:iterator in struts2.3.1.2

Posted by Lukasz Lenart <lu...@apache.org>.
2012/9/24 Omar Ngarigari <ng...@yahoo.com>:
> Hello,
>
> I changed my JSP page as per the documentation recommendation:
>
> <s:iterator value="myList" var="record">
> <s:property value="#record.ageNumber"/>
> <s:property value="#record.name"/>
> <s:checkbox name="age" value="%{#record.ageNumber}"/>
> </iterator>

And works ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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


Re: s:checkbox inside s:iterator in struts2.3.1.2

Posted by Omar Ngarigari <ng...@yahoo.com>.
Hello,

I changed my JSP page as per the documentation recommendation:

<s:iterator value="myList" var="record">
<s:property value="#record.ageNumber"/>
<s:property value="#record.name"/>
<s:checkbox name="age" value="%{#record.ageNumber}"/>
</iterator> 



________________________________
 From: Lukasz Lenart <lu...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org>; Omar Ngarigari <ng...@yahoo.com> 
Sent: Monday, September 24, 2012 12:50 AM
Subject: Re: s:checkbox inside s:iterator in struts2.3.1.2
 
2012/9/24 Omar Ngarigari <ng...@yahoo.com>:
> Hello,
>
> Please help, I am having problem that I cannot figure out how to solve it. The problem is as follow:
>
> 1. JSP page:
> <s:iterator value="myList" var="record">
> <s:property value="#record.ageNumber"/>
> <s:property value="#record.name"/>
> <s:checkbox name="stringList" fieldValue="%{age}"/>
> </iterator>
>
> 2. Action Class
> public class ExampleAction extends ActionSupport {
> private List<Pojo> myList = new ArrayList<Pojo>();
> private List<String> stringList = new ArrayList<String>();
> private int age;
> getter/setters()
>
> public String execute(){
> generatePDFFile(age);
> return Action.SUCCESS;
> }
>
 }
>
> My problem is I don't know how to get the age in checkbox at JSP page back in the action class to generate PDF file. The PDF file is generated based on the age from the JSP. Is there any one can help me to achieve that.

Please check the documentation [1] as I've mixed attributes, attribute
name is the name of property to set, attribute fieldValue will be
evaluated to HTML attribute value (true/false) - check the examples in
the doc.

[1] http://struts.apache.org/2.x/docs/checkbox.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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

Re: s:checkbox inside s:iterator in struts2.3.1.2

Posted by Omar Ngarigari <ng...@yahoo.com>.
Hello,

I changed my JSP page as per the documentation recommendation:

<s:iterator value="myList" var="record">
<s:property value="#record.ageNumber"/>
<s:property value="#record.name"/>
<s:checkbox name="age" value="%{#record.ageNumber}"/>
</iterator> 


However. the error is still displaying. com.opensymphony.xwork2.ognl.OgnlValueStack] Error setting expression 'age' with value '[Ljava.lang.String;@1cf93cb': ognl.MethodFailedException: Method "setAge" failed for object

________________________________
 From: Lukasz Lenart <lu...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org>; Omar Ngarigari <ng...@yahoo.com> 
Sent: Monday, September 24, 2012 12:50 AM
Subject: Re: s:checkbox inside s:iterator in struts2.3.1.2
 
2012/9/24 Omar Ngarigari <ng...@yahoo.com>:
> Hello,
>
> Please help, I am having problem that I cannot figure out how to solve it. The problem is as follow:
>
> 1. JSP page:
> <s:iterator value="myList" var="record">
> <s:property value="#record.ageNumber"/>
> <s:property value="#record.name"/>
> <s:checkbox name="stringList" fieldValue="%{age}"/>
> </iterator>
>
> 2. Action Class
> public class ExampleAction extends ActionSupport {
> private List<Pojo> myList = new ArrayList<Pojo>();
> private List<String> stringList = new ArrayList<String>();
> private int age;
> getter/setters()
>
> public String execute(){
> generatePDFFile(age);
> return Action.SUCCESS;
> }
> }
>
> My problem is I don't know how to get the age in checkbox at JSP page back in the action class to generate PDF file. The PDF file is generated based on the age from the JSP. Is there any one can help me to achieve that.

Please check the documentation [1] as I've mixed attributes, attribute
name is the name of property to set, attribute fieldValue will be
evaluated to HTML attribute value (true/false) - check the examples in
the doc.

[1] http://struts.apache.org/2.x/docs/checkbox.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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

Re: s:checkbox inside s:iterator in struts2.3.1.2

Posted by Lukasz Lenart <lu...@apache.org>.
2012/9/24 Omar Ngarigari <ng...@yahoo.com>:
> Hello,
>
> Please help, I am having problem that I cannot figure out how to solve it. The problem is as follow:
>
> 1. JSP page:
> <s:iterator value="myList" var="record">
> <s:property value="#record.ageNumber"/>
> <s:property value="#record.name"/>
> <s:checkbox name="stringList" fieldValue="%{age}"/>
> </iterator>
>
> 2. Action Class
> public class ExampleAction extends ActionSupport {
> private List<Pojo> myList = new ArrayList<Pojo>();
> private List<String> stringList = new ArrayList<String>();
> private int age;
> getter/setters()
>
> public String execute(){
> generatePDFFile(age);
> return Action.SUCCESS;
> }
> }
>
> My problem is I don't know how to get the age in checkbox at JSP page back in the action class to generate PDF file. The PDF file is generated based on the age from the JSP. Is there any one can help me to achieve that.

Please check the documentation [1] as I've mixed attributes, attribute
name is the name of property to set, attribute fieldValue will be
evaluated to HTML attribute value (true/false) - check the examples in
the doc.

[1] http://struts.apache.org/2.x/docs/checkbox.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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