You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Swapnil Patil <sw...@gmail.com> on 2005/08/04 08:52:45 UTC

Problem in populating html controls from Bean...

HI all,
   I want to populate html :text from someBean (request scope) 
    and also want to associate that html:text with FormBean.

    My jsp page is like this 
    
    
    <jsp:useBean	id="someBean" 
				scope="request" 
				type="SomeBean" />			
				
    <html:form action="/DisplayGraphStep2">    

    	Title  :  
<html:text property="title" value="<bean:write name="someBean"        
                  property ="oldTitle"/>" >   </html:text >

    </html:form>
    
    
    I am getting an excepiton for this code.
    
    
    I want to popoulate the text box with the value of '
someBean.oldTitle ' and also want to associate text box with  '
ormBeans.title '.
    
   Can anybody help me....
   
   Thanks & Regards
   Swapnil

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


Re: Problem in populating html controls from Bean...

Posted by Laurie Harper <la...@holoweb.net>.
Wendy Smoak wrote:
> From: "Laurie Harper" <la...@holoweb.net>
>> This really should be an FAQ :-) The problem is that it's not legal to
>> nest JSP tags that way. Try:
>>
>>   <html:text property="title" value="${someBean.oldTitle}>
>> or
>>   <html:text property="title" value="<%= someBean.getOldTitle() %>">
> 
> That prevents the framework from re-displaying the user's input if the 
> form fails
> validation.
> 
> At the risk of repeating myself:  the place to pre-populate your form beans
> is in the Action, before you forward to the JSP.

Good point. I really *must* try and remember that everyone else does it 
this way ;-) [that's the problem with using non-standard design patterns!]

L.
-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


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


Re: Problem in populating html controls from Bean...

Posted by Rick Reumann <st...@reumann.net>.
Wendy Smoak wrote the following on 8/4/2005 1:27 PM:

>>   <html:text property="title" value="${someBean.oldTitle}>

> That prevents the framework from re-displaying the user's input if the 
> form fails
> validation.
> 
> At the risk of repeating myself:  the place to pre-populate your form beans
> is in the Action, before you forward to the JSP.

Yes exactly.

And if you are going to hardcode the value in there then you might as 
well not even use the Struts html tags?

<html:text property="title" value="${someBean.oldTitle}>

Could just become

<input type="text" name="title" value="${someBean.oldTitle}"/>

Occasionaly I will set a value manually in my JSP but for the most part, 
as Wendy states, this is usually a very bad practice Swapnil (form bean 
properties should be in place before going to the JSP).

-- 
Rick

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


Re: Problem in populating html controls from Bean...

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Laurie Harper" <la...@holoweb.net>

> This really should be an FAQ :-) The problem is that it's not legal to
> nest JSP tags that way. Try:
>
>   <html:text property="title" value="${someBean.oldTitle}>
> or
>   <html:text property="title" value="<%= someBean.getOldTitle() %>">

That prevents the framework from re-displaying the user's input if the form 
fails
validation.

At the risk of repeating myself:  the place to pre-populate your form beans
is in the Action, before you forward to the JSP.

-- 
Wendy Smoak


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


Re: Problem in populating html controls from Bean...

Posted by Laurie Harper <la...@holoweb.net>.
This really should be an FAQ :-) The problem is that it's not legal to nest 
JSP tags that way. Try:

   <html:text property="title" value="${someBean.oldTitle}>

or

   <html:text property="title" value="<%= someBean.getOldTitle() %>">

L.

Swapnil Patil wrote:

> HI all,
>    I want to populate html :text from someBean (request scope) 
>     and also want to associate that html:text with FormBean.
> 
>     My jsp page is like this 
>     
>     
>     <jsp:useBean	id="someBean" 
> 				scope="request" 
> 				type="SomeBean" />			
> 				
>     <html:form action="/DisplayGraphStep2">    
> 
>     	Title  :  
> <html:text property="title" value="<bean:write name="someBean"        
>                   property ="oldTitle"/>" >   </html:text >
> 
>     </html:form>
>     
>     
>     I am getting an excepiton for this code.
>     
>     
>     I want to popoulate the text box with the value of '
> someBean.oldTitle ' and also want to associate text box with  '
> ormBeans.title '.
>     
>    Can anybody help me....
>    
>    Thanks & Regards
>    Swapnil


-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


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