You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by neo anderson <ja...@yahoo.co.uk> on 2009/09/16 20:08:59 UTC

Add a column to beaneditform question

I have an user object which contains several properties, including account,
name, gender and password. However, due to the object only provide
getAccount() method. So when displaying using beaneditform, the web page
does not show the Account column. 

Then I search the forum

http://www.nabble.com/-T5--How-to-add-a-extra-column-for-delete-update-action-using-Grid-component.-td12255655.html#a12258689
http://www.nabble.com/T5-%3A-Rendering-one-column-in-Grid-compoenent-made-the-paging-disappeared---td14565259.html#a14565259

and add the following lines to create a column called Account after using
beanModel to create required BeanModel. 

	model = beanModelSource.create(User.class, ...); 
	model.add("account", null).label("Account").sortable(false); 

Unfortunately, after compilation and deployment, the web page still do not
show the column Account. Is this the right way to add a new column to
beaneditform? Or what is the correct way to achieve such purpose?

I appreciate any suggestion,

Thank you.


-- 
View this message in context: http://www.nabble.com/Add-a-column-to-beaneditform-question-tp25477600p25477600.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Add a column to beaneditform question

Posted by neo anderson <ja...@yahoo.co.uk>.

result in error:
@Property(write=false) 
@Retain
private BeanModel model;

work version:
@Property
@Retain
private BeanModel model;


I sovle this problem. The problem comes from the above annotation where
there is an attribute named `write' that should be removed (I thought it was
removed but indeed it was not) so that the bean model can add new column. 

Thanks for the help.

I appreciate it. 


-- 
View this message in context: http://www.nabble.com/Add-a-column-to-beaneditform-question-tp25477600p25530674.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Add a column to beaneditform question

Posted by neo anderson <ja...@yahoo.co.uk>.
The tml is

	<t:beaneditform submitlabel="Register" object="user" remove="page"
model="registerModel">
		<t:parameter name="account">
			<t:label for="Account"/> 
			<t:textField t:id="account" t:model="user" t:value="user.account"
t:validate="required,regexp"/> 
		</t:parameter>
		<t:parameter name="name">
			<t:label for="Name"/> 
			<t:textField t:id="name" t:model="user" t:value="user.name"
t:validate="required,minlength=5"/> 
		</t:parameter>
		<t:parameter name="password">
			<t:label for="Password"/> 
			<t:passwordField t:id="password" t:model="user" t:value="user.password"
t:validate="required,minlength=2"/> 
		</t:parameter> 
		<t:parameter name="sex">
			<t:label for="Sex"/> 
			<t:select t:id="sex" t:model="genders" t:value="user.sex"
t:blankOption="never"/> 
		</t:parameter> 
		
	</t:beaneditform>

and page object contains 

	@Inject
	private ModelCreator displayer;

	@Property
	@Retain
	private BeanModel model;

	@Property
	private User user;

...

	public BeanModel getRegisterModel(){
		// change to pass in from ui (let user choose from ui)
		String lang = Locale.ENGLISH.getDisplayLanguage();
		String country = Locale.US.getDisplayCountry();

		model = displayer.createBeanModel(User.class, lang, country);
		model.add("account", null).label("Account").sortable(false); 
		return model;
	}

	public SelectModel getGenders(){
		return displayer.createGender();
		
	}


in ModelCreator.java

	public BeanModel createBeanModel(Class clazz, String lang, String country){
		if(null == source) throw new NullPointerException("No BeanModelSource
configured!");

		if(null == cache.get(BeanModel.class)){
			ClassLoader loader = Thread.currentThread().getContextClassLoader(); 
			URL url = loader.getResource("messages_en_US.properties");
			String path = url.getPath();
			BeanModel model = null;
			try{
				ResourceBundle bundle = new PropertyResourceBundle(new
FileInputStream(path));
				model = source.create( clazz, true, new MessagesImpl(new Locale(lang,
country), bundle) );
			}catch(IOException ioe){
				ioe.printStackTrace();
			}
			cache.put(BeanModel.class, model);
		}
		return (BeanModel)cache.get(BeanModel.class);
	}




Thiago H. de Paula Figueiredo wrote:
> 
> Please post your template.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> Consultor, desenvolvedor e instrutor em Java
> Coordenador e professor da Especialização em Engenharia de Software com  
> Ênfase em Java da Faculdade Pitágoras
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Add-a-column-to-beaneditform-question-tp25477600p25530611.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Add a column to beaneditform question

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Please post your template.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org