You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2010/06/02 17:39:39 UTC

How JSP page retrieves ActionForm.bean value?

Good morning List,

Could someone tell me how to read actionForm's bean value please?

(1) Bean.java
     String name;
     ... ...

(2) Action class
public class ProcessAction extends ActionSupport
{
    Bean bean1 = new Bean();
... ...
}

(3) JSP file
Here is my question!
<form action="ProcessAction" ...>
<%
   String name = bean1.getName();
%>
... ...
</form>

How to assign bean1.name to string name in jsp file please?

Thanks a lot!

--
Lu Ying


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


Re: How JSP page retrieves ActionForm.bean value?

Posted by Cimballi <ci...@cimballi.net>.
You should not write java code inside JSPs, it's very hard to maintain.
You should use Struts taglib and JSTL taglibs.
Look at the <c:set> tag and also ${} to display bean values.

Cimballi


On Wed, Jun 2, 2010 at 12:22 PM, Emi Lu <em...@encs.concordia.ca> wrote:
>>> Could someone tell me how to read actionForm's bean value please?
>>> (1) Bean.java
>>>      String name;
>>>      ... ...
>>
>> You have a getName and setName methods right?
>>
>>> (2) Action class
>>> public class ProcessAction extends ActionSupport
>>> {
>>>     Bean bean1 = new Bean();
>>> ... ...
>>> }
>
>> You have a getBean and setBean methods right?
>
>
>
>>> (3) JSP file
>>> Here is my question!
>>> <form action="ProcessAction"  ...>
>>> <%
>>>    String name = bean1.getName();
>>> %>
>>> ... ...
>>> </form>
>>>
>>> How to assign bean1.name to string name in jsp file please?
>>
>> If you have declared yous struts tags as such:
>>
>> <%@ taglib prefix="s"  uri="/struts-tags"  %>
>
>
>
>> <s:property value="bean.name" />
>
> This is not what I want!
>
> I want to save form.bean.fieldValue into a <% String str = bean.fieldValue
> %>
>
> And then str will be used for other purposes. For example, <display:table
> pageSize=<%=str %>
>
> I do not want to display the property at all!
>
> --
> Lu Ying
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Cimballi
JAVA J2EE Freelance
http://javajeeleader.elance.com/

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


Re: How JSP page retrieves ActionForm.bean value?

Posted by Emi Lu <em...@encs.concordia.ca>.
>> Could someone tell me how to read actionForm's bean value please?
>> (1) Bean.java
>>       String name;
>>       ... ...
> You have a getName and setName methods right?
>
>> (2) Action class
>> public class ProcessAction extends ActionSupport
>> {
>>      Bean bean1 = new Bean();
>> ... ...
>> }

> You have a getBean and setBean methods right?



>> (3) JSP file
>> Here is my question!
>> <form action="ProcessAction"  ...>
>> <%
>>     String name = bean1.getName();
>> %>
>> ... ...
>> </form>
>>
>> How to assign bean1.name to string name in jsp file please?
> If you have declared yous struts tags as such:
>
> <%@ taglib prefix="s"  uri="/struts-tags"  %>



> <s:property value="bean.name" />

This is not what I want!

I want to save form.bean.fieldValue into a <% String str = 
bean.fieldValue %>

And then str will be used for other purposes. For example, 
<display:table pageSize=<%=str %>

I do not want to display the property at all!

--
Lu Ying





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