You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Raghuveer <ra...@infotechsw.com> on 2005/12/09 15:07:06 UTC

Nested Properties

In My web application
I have one ActionForm and in that I have one getter setter method for other
java bean.

In my JSP i want to access the Java bean for display .Display is working
fine as text box value and display with bean:write.

But whene ever i submit the JSP page ..How to the value is set to  Java bean
in ActionForm?




------------------------------------
//Action form
package com.utc.iae.ip.actionforms;


import com.bean.ClassJavaBean;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionMapping;

public class ClassActionForm extends ActionFOrm {

	   private classJavaBean obj=null



	public ClassActionForm() {
		super();
		// TODO Auto-generated constructor stub
	}

   public ClassJavaBean getClassJavaBean(){
	classJavaBean
   }

   public ClassJavaBean setClassJavaBean(ClassJavaBean newobg){
	this.obg=newobg
   }

}
-------------------------
//bean class
public class ClassJavaBean implements java.io.Serializable
{

private String model;


	public String getModel() {
		return model;
	}


	public void setModel(String mod) {
		this.model = mod;
	}

};


----------------------------------

// jsp

 <bean:define id="classJavaBean" name="ClassActionForm"
property="ClassJavaBean"/>

 <bean:write name="classJavaBean" property="model" />




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


Re: Nested Properties

Posted by Laurie Harper <la...@holoweb.net>.
Raghuveer wrote:
> In My web application
> I have one ActionForm and in that I have one getter setter method for other
> java bean.
> 
> In my JSP i want to access the Java bean for display .Display is working
> fine as text box value and display with bean:write.
> 
> But whene ever i submit the JSP page ..How to the value is set to  Java bean
> in ActionForm?

I'm not sure what you're asking there; are you asking how to get the 
text box value into the form bean after the user edits it? If so, one of 
the errors below might be part of your problem:

> ------------------------------------
> //Action form
> package com.utc.iae.ip.actionforms;
> 
> import com.bean.ClassJavaBean;
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.ActionMapping;
> 
> public class ClassActionForm extends ActionFOrm {
> 	   private classJavaBean obj=null
> ...
>    public ClassJavaBean getClassJavaBean(){
> 	classJavaBean
>    }
> 
>    public ClassJavaBean setClassJavaBean(ClassJavaBean newobg){
> 	this.obg=newobg
>    }
> }

Setters should have a 'void' return. Since yours declares it returns 
ClassJavaBean, it's not recognized as a write method for the 
classJavaBean property.

> -------------------------
> //bean class
> public class ClassJavaBean implements java.io.Serializable
> {
> private String model;
> 
> 	public String getModel() {
> 		return model;
> 	}
> 
> 	public void setModel(String mod) {
> 		this.model = mod;
> 	}
> };

Looks OK.

> ----------------------------------
> // jsp
> 
>  <bean:define id="classJavaBean" name="ClassActionForm"
> property="ClassJavaBean"/>
> 
>  <bean:write name="classJavaBean" property="model" />

So you're saying this *is* working for you? You don't have anything here 
that will output a text box, though, so nothing the user can edit and, 
since there's no form here either, nothing the user can submit back.

Also, property="ClassJavaBean" should be property="classJavaBean" (note 
the case of the property name) so if it is working, I'm surprised.

L.


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