You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tapbeg <eg...@hotmail.com> on 2012/03/28 19:36:06 UTC

writer.writeRaw(String text)

Hi,

to show forms with dynamic fields, I have a loop as follows:



As you see, I only show textfields. What I want is to show other types such
as select, radio button... depending on attribute "typeOfField" of Field.
So, I want to do is something like a "factory widget". I think it's possible
to solve this by using writeRaw, where string would be the piece of correct
code of that factory. I have been searching for an example of doing this
with writeRaw, but I didn't find anything.

Could you help me?

Thank you!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/writer-writeRaw-String-text-tp5601234p5601234.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: writer.writeRaw(String text)

Posted by Tapbeg <eg...@hotmail.com>.
trsvax wrote
> 
> I did something similar to this by creating a BeanModel
> 
> 	@Property
> 	private Map&lt;String, Object&gt; args;
> 
> BeanModel model = beanModelSource.createEditModel(args.getClass(),
> resources.getMessages());
> 
> and then add the datatypes I wanted like this
> 
> model.add(name, mapConduit(name,clazz)).dataType(datatype);
> 
> mapConduit looks like this
> 
> PropertyConduit mapConduit(final String key, final Class<?> datatype) {
> 		return new PropertyConduit() {
> 			
> 			@Override
> 			public <T extends Annotation> T getAnnotation(Class<T> clazz) {
> 				return null;
> 			}
> 			
> 			@Override
> 			public void set(Object instance, Object value) {
> 				((Map)instance).put(key, value);			
> 			}
> 			
> 			@Override
> 			public Class getPropertyType() {
> 				return datatype;
> 			}
> 			
> 			@Override
> 			public Object get(Object instance) {
> 				return ((Map) instance).get(key);
> 			}
> 		};
> 	}
> 
> Then the tml just has
> 
> 	<t:beaneditform object="args" model="model"/>
> 


It could be very useful to me. 

Thank you all.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/writer-writeRaw-String-text-tp5601234p5601842.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: writer.writeRaw(String text)

Posted by trsvax <tr...@gmail.com>.
I did something similar to this by creating a BeanModel

	@Property
	private Map<String, Object> args;

BeanModel model = beanModelSource.createEditModel(args.getClass(),
resources.getMessages());

and then add the datatypes I wanted like this

model.add(name, mapConduit(name,clazz)).dataType(datatype);

mapConduit looks like this

PropertyConduit mapConduit(final String key, final Class<?> datatype) {
		return new PropertyConduit() {
			
			@Override
			public <T extends Annotation> T getAnnotation(Class<T> clazz) {
				return null;
			}
			
			@Override
			public void set(Object instance, Object value) {
				((Map)instance).put(key, value);			
			}
			
			@Override
			public Class getPropertyType() {
				return datatype;
			}
			
			@Override
			public Object get(Object instance) {
				return ((Map) instance).get(key);
			}
		};
	}

Then the tml just has

	<t:beaneditform object="args" model="model"/>

--
View this message in context: http://tapestry.1045711.n5.nabble.com/writer-writeRaw-String-text-tp5601234p5601626.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: writer.writeRaw(String text)

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 28 Mar 2012 18:27:38 -0300, Tapbeg <eg...@hotmail.com> wrote:

> Thiago H de Paula Figueiredo wrote
>>
>> Gosh, did you even try to read the documentation and try the component  
>> in> your project before asking in the mailing list?
>>
>> public String getMyHtml() {
>> 	return " \"www.google.com\" Google ";
>> }
>>
>> <t:outputraw value="myHtml"/>
>>
>
> Yes, I did. I was doing it in the wrong way, that's way I've asked.  
> Anyway, I'm sorry and excuse me :(

No need to apologize. Just tells us upfront what you've tried and what was  
the result. Otherwise, we would think you didn't even try, and that's what  
I thought. :)

> Thank you very much.

:)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: writer.writeRaw(String text)

Posted by Tapbeg <eg...@hotmail.com>.
Thiago H de Paula Figueiredo wrote
> 
> 
> Gosh, did you even try to read the documentation and try the component in  
> your project before asking in the mailing list?
> 
> public String getMyHtml() {
> 	return " \"www.google.com\" Google ";
> }
> 
> <t:outputraw value="myHtml"/>
> 

Yes, I did. I was doing it in the wrong way, that's way I've asked. Anyway,
I'm sorry and excuse me :(

Thank you very much.








--
View this message in context: http://tapestry.1045711.n5.nabble.com/writer-writeRaw-String-text-tp5601234p5601837.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: writer.writeRaw(String text)

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 28 Mar 2012 16:38:17 -0300, Tapbeg <eg...@hotmail.com> wrote:

> Could you type a very simple example of how to use OutputRaw as you say?

Gosh, did you even try to read the documentation and try the component in  
your project before asking in the mailing list?

public String getMyHtml() {
	return "<a href=\"www.google.com\">Google</a>";
}

<t:outputraw value="myHtml"/>

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: writer.writeRaw(String text)

Posted by Tapbeg <eg...@hotmail.com>.
Thiago H de Paula Figueiredo wrote
> 
> 
> You could use the OutputRaw component, which uses MarkupWriter.writeRaw()  
> internally.
> But I suggest you something completely different: take a look at how the  
> BeanModel-based components work (Grid, BeanEditForm, BeanModel,  
> BeanDisplay) and also specifically PropertyEditor and Display. They do  
> something very, very similar to what you want to implement, but without  
> resorting to raw HTML, using blocks and components instead.
> 
> 

Could you type a very simple example of how to use OutputRaw as you say? 

I will take a look at what you suggest.

Thank you very much for your answer.


--
View this message in context: http://tapestry.1045711.n5.nabble.com/writer-writeRaw-String-text-tp5601234p5601522.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: writer.writeRaw(String text)

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 28 Mar 2012 14:36:06 -0300, Tapbeg <eg...@hotmail.com> wrote:

> Hi,

Hi!

> So, I want to do is something like a "factory widget". I think it's  
> possible to solve this by using writeRaw, where string would be the  
> piece of correct code of that factory. I have been searching for an  
> example of doing this
> with writeRaw, but I didn't find anything.

You could use the OutputRaw component, which uses MarkupWriter.writeRaw()  
internally.
But I suggest you something completely different: take a look at how the  
BeanModel-based components work (Grid, BeanEditForm, BeanModel,  
BeanDisplay) and also specifically PropertyEditor and Display. They do  
something very, very similar to what you want to implement, but without  
resorting to raw HTML, using blocks and components instead.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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