You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Anbazhagan.G" <an...@snovabits.net> on 2014/01/24 05:28:03 UTC

Getting tml page output without HTML tags

Hi All,

I am using Tapestry5.3. I have a dynamic web project (prject name: test) 
with test.tml and test.java.

*Test.tml*
<!DOCTYPE html>
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
       xmlns:p="tapestry:parameter">
<head>
</head>
<body>
${stringValue}
</body>
</html>

*Test.Java*
public String getGenerateJson() {
return "welcome";
}

I have one more dynamic web project (project name: test2) with test2.tml 
and test2.java. Both projects are running into my tomcat server.

 From test2.java, I make a http connetion to test.java for getting olny 
test.java return value (welcome) in test2.java.

*Test2.Java*

final GetData data = new HttpGetData();
final String str = data.getContent("http://10.0.1.62:8080/Test/test");
System.out.println("String: " + str);

*Output:*

String: <!DOCTYPE html><html 
xmlns="http://www.w3.org/1999/xhtml"><head><link type="text/css" 
rel="stylesheet" 
href="/test/assets/1b4371c8cdb7af3/core/default.css"/><link 
type="text/css" rel="stylesheet" 
href="/test/assets/1b4371c8cdb7af3/jquery/themes/ui-lightness/jquery-ui-1.8.15.custom.css"/><meta 
content="Apache Tapestry Framework (version 5.3.1)" 
name="generator"/></head><body>
welcome
</body></html>

But I got output like that.

Is chance to get only welcome from test.java. Please give me your 
valuable suggestion or idea to achieve like that.

Regards,
G.Anbazhagan


Re: Getting tml page output without HTML tags

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 24 Jan 2014 10:17:55 -0200, Thiago H de Paula Figueiredo  
<th...@gmail.com> wrote:

> 	return new TextOutputStream("application/json", getGenerateJson());

Correction: it's TextStreamResponse, not TextOutputStream.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Getting tml page output without HTML tags

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 24 Jan 2014 02:28:03 -0200, Anbazhagan.G  
<an...@snovabits.net> wrote:

> Hi All,

Hi!

>  From test2.java, I make a http connetion to test.java for getting olny
> test.java return value (welcome) in test2.java.

You requested the page, not the result from getGenerateJson(), so it is  
absolutely correct that you get the whole page as the result of your HTTP  
GET.

> Is chance to get only welcome from test.java. Please give me your
> valuable suggestion or idea to achieve like that.

Add this method to Test.java:

Object onActivate() {
	return new TextOutputStream("application/json", getGenerateJson());
}

Tapestry pages don't need to have a template, as long as you return  
content in an onActivate() content.

Also take a look at the JSONObject and JSONArray classes from Tapestry.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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