HTMLTemplateWidget

22 views
Skip to first unread message

Taras Petrytsyn

unread,
Jan 27, 2008, 1:01:15 PM1/27/08
to Google Web Toolkit
Here link to widget which allow use html files in your pages design
instead making design in Java classes

http://code.google.com/p/htmltemplatewidget/

Sorry for absence of detailed documentation, I will fix it soon, for
now you may ask any questions here.

I will be very greateful for your remarks to this widget.

NN

unread,
Jan 27, 2008, 4:51:58 PM1/27/08
to Google Web Toolkit
I am exactly doing this in Java code differently or more or less same.
I will try out your widget. But timing is so perfect. You hit the bull
eye saying Java code is free of UI design because HTML/CSS is designer
problem and our life become less problematic.

Thank you,

Taras Petrytsyn

unread,
Jan 27, 2008, 4:58:20 PM1/27/08
to Google Web Toolkit
If you will have any addiditional questions/troubles or some
suggestion/ideas about improving notify me.

Thanks

NN

unread,
Jan 27, 2008, 5:15:02 PM1/27/08
to Google Web Toolkit
But I am doing same with in following way which is one and same thing
without your widget class

here it is html file is ushow.html

<html>
<table>
<tr><td id="emailLabel"></td><td id="emailText"></tr>
</table>
</html>

Now in Java code

RootPanel rootPanel = RootPanel.get("ushow.html");
rootPanel.get("emailLabel").add(new Label("Enter your email"));
rootPanel.get("emailText").add(new TextBox());

even you can have your html in java code and using <div> element like
this

<html>
<div id="table"></div>
</html>

in java code

String html="<table> <tr><td id="emailLabel"></td><td id="emailText"></
tr></table>";
HTML html = new HTML(html);
RootPanel rootPanel = RootPanel.get("ushow.html");
rootPanel.get("table").add(html);


Now you can change your html code dynamically anywhere in page and
without loading multiple HTML pages for different usage. But you have
HTML inside
your java code but you only have dynamic HTML code and static stays
same (if you have any).

Now with your class we have more HTML where I am just dumping TextBox
using HTML ids. With any approach we have to use GWT stylename method
i.e. setStyleName() for textbox.

Hope I am clear and you tell how your class help me more.

Thanks

Taras Petrytsyn

unread,
Jan 27, 2008, 5:39:28 PM1/27/08
to Google Web Toolkit
There are meny injurious things, IMHO.

html in your Java code, it complicate work with design, becouse you
need make copy pastes from Java code editor to HTML editor to fix or
change design and backwards(fix html design in java code IDE isn't
good) and you cannot separeta working with design and Java
programming, in my project designer works with html independently of
my changes in Java code, and I'm not worring about it at all, all I
need to do just add id attributes to HTML when I add new control. I do
not need to change design, he doesn't need change Java code :)
But your solution tie Java code and HTML very much.

>
> Now with your class we have more HTML where I am just dumping TextBox
> using HTML ids. With any approach we have to use GWT stylename method
> i.e. setStyleName() for textbox.

No we have not! You can write css and styles in HTML like

<html>
<div id="table" style="color: #090"></div>
</html>

or

<html>
<div id="table" class="myClass"></div>
</html>

file and HTMLTemplate will get it and set it to widget you added by
id "table". isn't it helpful?

>
> Hope I am clear and you tell how your class help me more.

Does it help you?

Thanks

NN

unread,
Jan 27, 2008, 5:57:48 PM1/27/08
to Google Web Toolkit
I got it and knew that in my solution HTML stays inside Java but not
solution till date since designer is not ready with anything (in fact
is not hired yet)


Hope you will monitor forum for suggestion and bugs.

Thanks a lot for widget .

Taras Petrytsyn

unread,
Jan 27, 2008, 6:00:46 PM1/27/08
to Google Web Toolkit
You may post bugs/issues and write your suggestions here
http://code.google.com/p/htmltemplatewidget/ in Wiki and Issues tabs

Thanks

NN

unread,
Jan 27, 2008, 6:47:29 PM1/27/08
to Google Web Toolkit
Yeah one more thing I forgot was if I have HTML inside Java I can set
something like this

HTML html = new HTML("<table><tr><td =\"firstname\"></tr></table>");
rootPanel.get("firstname").add(html);

Now on certain business logic I want to display different HTML in
ushow.html page. I can easily do that in java by
html.setVisible(false); and set new html in that place by new
HTML("<span>Hello welcome to me page</span>");

With you widget I have to load different html page with because html
code in html page can't change by anybody. But if you do that from
Java you can make it visible or invisible using single statement and
you have one HTML for entire application (again depends on your
application)

Just another thought..

Thanks


On Jan 27, 3:00 pm, Taras Petrytsyn <pegasus...@gmail.com> wrote:
> You may post bugs/issues and write your suggestions herehttp://code.google.com/p/htmltemplatewidget/in Wiki and Issues tabs

Ian Bambury

unread,
Jan 27, 2008, 7:16:50 PM1/27/08
to Google-We...@googlegroups.com
Hi Taras,
 
The whole of http://examples.roughian.com is designed this way along with a menu system, automatic history support and it's spiderable. The framework is available for download, as is the demo at http://examples.roughian.com/RXFramework/
 
Ian

 

Taras Petrytsyn

unread,
Jan 28, 2008, 5:11:11 AM1/28/08
to Google Web Toolkit
> Yeah one more thing I forgot was if I have HTML inside Java I can set
> something like this
>
> HTML html = new HTML("<table><tr><td =\"firstname\"></tr></table>");
> rootPanel.get("firstname").add(html);
> Now on certain business logic I want to display different HTML in
> ushow.html page. I can easily do that in java by
> html.setVisible(false); and set new html in that place by new
> HTML("<span>Hello welcome to me page</span>");
>
> With you widget I have to load different html page with because html
> code in html page can't change by anybody. But if you do that from
> Java you can make it visible or invisible using single statement and
> you have one HTML for entire application (again depends on your
> application)

As for me I use many HTMLTemplateWidgets in project, one HTMLTemplate
per page aproximatelly, I have root HTMLTemplate and HTMLTemplates in
it, for simple example:
root.html:
<div id="header"></div>
<div id="menu"></div>
<div id="main"></div>
<div id="footer"></div>


final HTMLTemplateWidget root = new HTMLTemplateWidget(
"root.html");
final HTMLTemplateWidget header = new HTMLTemplateWidget(
"header.html");
final HTMLTemplateWidget footer = new HTMLTemplateWidget(
"footer.html");
final HTMLTemplateWidget menu = new HTMLTemplateWidget(
"menu.html");
final HTMLTemplateWidget main = new HTMLTemplateWidget(
"main.html");
root.addWidget("header", header);
root.addWidget("menu", menu);
root.addWidget("footer", footer);
root.addWidget("main", main);

and later I just replace widget with id "main" like:
final HTMLTemplateWidget main2 = new HTMLTemplateWidget(
"main2.html");
root.addWidget("main",main2);

so your header, footer and menu keeps and just main page reloads

you do not need have only one HTMLTemplateWidget per application

Thanks

> Just another thought..
>
> Thanks
>
> On Jan 27, 3:00 pm, Taras Petrytsyn <pegasus...@gmail.com> wrote:
>
>
>
> > You may post bugs/issues and write your suggestions herehttp://code.google.com/p/htmltemplatewidget/inWiki and Issues tabs
> > > > > > > > I will be very greateful for your remarks to this widget.- Сховати цитований текст -
>
> - Показати цитований текст -

Taras Petrytsyn

unread,
Jan 28, 2008, 5:17:08 AM1/28/08
to Google Web Toolkit
I look at you framework - automated history is very good stuff, but
where is separation of View side from Controller in your framework?

On 28 Січ, 02:16, "Ian Bambury" <ianbamb...@gmail.com> wrote:
> Hi Taras,
>
> The whole ofhttp://examples.roughian.comis designed this way along with a
> menu system, automatic history support and it's spiderable. The framework is
> available for download, as is the demo athttp://examples.roughian.com/RXFramework/
>
> Ian
>
> On 27/01/2008, Taras Petrytsyn <pegasus...@gmail.com> wrote:
>
>
>
>
>
>
>
> > You may post bugs/issues and write your suggestions here
> >http://code.google.com/p/htmltemplatewidget/in Wiki and Issues tabs
> --
> Ian
>
> http://examples.roughian.com- Сховати цитований текст -

江永源

unread,
Jan 28, 2008, 5:34:43 AM1/28/08
to Google Web Toolkit
haha,i have the same project with it :
http://code.google.com/p/macaufly-gwt-tool/downloads/list

江永源

unread,
Jan 28, 2008, 5:41:48 AM1/28/08
to Google Web Toolkit
i want to ask a question:

it use the iframe to load the template or read the content with
building?

Taras Petrytsyn

unread,
Jan 28, 2008, 5:46:41 AM1/28/08
to Google Web Toolkit
It doesn't use iframes, you can see it in source

Ian Bambury

unread,
Jan 28, 2008, 6:49:53 AM1/28/08
to Google-We...@googlegroups.com
Well, MVC isn't the be all and end all. If I use a button object, what do I care if it is MVC internally so long as it works. But, to answer your question:
 
In a menu, the view is the menupanel, the controller is the abstractmenubar.
 
In the code of someone using it, the view is the HTML page and the controller is whatever code you decide to put in the associated Java file. Obviously if you add widgets from the java class, what you do, and how you do it is up to you.

 

NN

unread,
Jan 28, 2008, 3:12:44 PM1/28/08
to Google Web Toolkit
nice one I will keep that in mind and look clean

Thanks
> > > You may post bugs/issues and write your suggestions herehttp://code.google.com/p/htmltemplatewidget/inWikiand Issues tabs

NN

unread,
Jan 28, 2008, 6:20:34 PM1/28/08
to Google Web Toolkit
Your widget has bug or I am doing it wrong but here the HTML code
where I am using your widget and create nasty UI

<html>
<head>

<link rel="stylesheet" type="text/css" href="styles.css" />

<script language='javascript' src='com.zs.web.Loaduser.nocache.js'></
script>
</head>
<body>

<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" style="width:
0;height:0;border:0"></iframe>


<table border=0 cellspacing=10>
<th id="home"></th> <th id="me">me</th><th id="vault"></th><th
id="logout"></th>
<tr><td colspan=4 align=center id="uname"><b></b></tr>
<tr><td id="primaryL"></td> <td id="primaryemail"></td> <td></td>
<td></td> <td></td><td id="chgPwd" colspan=4 align=right></td></tr>
<tr><td id="smsL"></td><td id="sms"></td><td id="verifiedS"></
td><td id="verifyS"></td><td id="cancelS"></td></tr>
<tr><td id="moreemails"></td></tr>
<tr><td id="email1L"></td><td id="email1"></td><td
id="verified1"></td><td id="verify1"></td><td id="cancel1"></td></tr>
<tr><td id="email2L"></td><td id="email2"></td><td
id="verified2"></td><td id="verify2"></td><td id="cancel2"></td></tr>
<tr><td id="email3L"></td><td id="email3"></td><td
id="verified3"></td><td id="verify3"></td><td id="cancel3"></td></tr>
<tr><td id="email4L"></td><td id="email4"></td><td
id="verified4"></td><td id="verify4"></td><td id="cancel4"></td></tr>
<tr><td id="email5L"></td><td id="email5"></td><td
id="verified5"></td><td id="verify5"></td><td id="cancel5"></td></tr>
<tr><td id="email6L"></td><td id="email6"></td><td
id="verified6"></td><td id="verify6"></td><td id="cancel6"></td></tr>
<tr><td id="email7L"></td><td id="email7"></td><td
id="verified7"></td><td id="verify7"></td><td id="cancel7"></td></tr>
<tr><td id="enteraddress"><td></tr>
<tr><td id="postalL"></td><td id="address1"></td><td
id="verified8"></td><td id="verify8"></td><td id="canceladd"></td></
tr>
<tr><td id="address2L"></td><td id="address2"></td></tr>
<tr><td id="cityL"></td><td id="city"></td></tr>
<tr><td id="zipL"></td><td id="zip"></td></tr>
<tr><td id="stateL"></td><td id="state"></td></tr>
<tr><td id="countryL"></td><td id="country"></td><td
id="edit"></td><td id="save"></td></tr>
<tr><td id="security" colspan=4 align=center></td></tr>
<tr><td id="secaddon" align=center colspan=4></td></tr>
<tr><td align=center colspan=4><a href="#"> what is level
of security?</a></td></tr>
</table>

</body>
</html>


output looks horrible.. everything is drawn in first column.

in java code I have

HTMLTemplateWidget html = new HTMLTemplateWidget("ushow.html");
ushow.html contain above code

html.addWidget("uname",new Label("John Smith"));

now above label is generated using name of user fetch from db (you
don't care more on that)

RootPanel.get().add(html);

if I had root.html which contains <div is="centertable"></div> then

RootPanel.get("root.html").add(html);

but even that doesn't do the trick because your widget mess my table
format or I did something wrong..

I am not sure your widget understand components are in HTML table or
they want HTML in particular way.

Can you tell me what is wrong??

Thanks
> > > > You may post bugs/issues and write your suggestions herehttp://code.google.com/p/htmltemplatewidget/inWikiandIssues tabs

Taras Petrytsyn

unread,
Jan 28, 2008, 6:31:24 PM1/28/08
to Google Web Toolkit
You missed one thing, my widget doesn't insert widget into tag with
specified id, its replace tag with specified id.

<tr><td colspan=4 align=center
id="uname"><b></b></tr> - this wouldn't work becouse you raplace <td>
output will be looks like

<tr>here widget you've been added</tr> that is why you have horroble
HTML, you have to do this way

<tr><td colspan=4 align=center ><div id="uname"></div></tr>

Note: you can use any type of tags div/input/span etc. it doesn't
metter, becouse HTMLTemplateWidget analyze only id style and class
attributes and doesn't anylize tag name.
> ...
>
> продолжение >>

Taras Petrytsyn

unread,
Jan 28, 2008, 6:34:11 PM1/28/08
to Google Web Toolkit
http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/ae0a4886a4f6f958
- here link there is one my post that explain HTMLTemplateWidget and
compare it work with works of HTMLPanel, you use id in way more looks
like it is in HTMLPanel

On 29 янв, 02:20, NN <neh...@gmail.com> wrote:
> ...
>
> продолжение >>

NN

unread,
Jan 28, 2008, 7:32:07 PM1/28/08
to Google Web Toolkit
Thanks for the tip. In my UI I have to enable and disable Label and
TextBox depending on different conditions. In that case your widget
isn't working..
> ...
>
> read more >>

Taras Petrytsyn

unread,
Jan 29, 2008, 2:50:42 AM1/29/08
to Google Web Toolkit
No, enabling/disableing, visibility, readonly etc. all this features
works, you must be do seomething wrong.
> ...
>
> read more >>

NN

unread,
Jan 29, 2008, 4:29:56 AM1/29/08
to Google Web Toolkit
HTMLTemplateWidget html = new HTMLTemplateWidget(ushow.html);

TextBox editText = new TextBox();
Label editLabel = new Label();
editText.setVisible(false);

html.addWidget("edit",editText);
html.addWidget("edit",saveText);

In above statement I set two widget at same location but make one
invisible and later on do reverse depending on business logic

editText.setVisible(true);
saveText.setVisible(false);

When I excute last statements it won't enable editText but set
saveText invisible.

Hope it is clear.

Thanks
> ...
>
> read more >>

NN

unread,
Jan 29, 2008, 4:36:18 AM1/29/08
to Google Web Toolkit
address2LH = new Label("second line:");
address2 = new TextBox();
address2.setText(zes_users.getAddress2());
address2.setVisible(false);
ushowHTML.addWidget("address2",address2);
address2L = new Label(zes_users.getAddress2());
if (zes_users.getAddress2().length() != 0){
ushowHTML.addWidget("address2L",address2LH);
ushowHTML.addWidget("address2",address2L);
> ...
>
> read more >>

Taras Petrytsyn

unread,
Jan 29, 2008, 5:04:22 AM1/29/08
to Google Web Toolkit
html.addWidget("edit",editText);
html.addWidget("edit",saveText);

here is problem, if you add widget to the same id second time first
widget is replacing by second!

That is why first one already is unavaible! It is replaced by second
one!
editText.setVisible(true);

, wh
> ...
>
> читати далі »- Сховати цитований текст -

NN

unread,
Jan 29, 2008, 5:15:18 AM1/29/08
to Google Web Toolkit
I know that is not problem when I am not using your widget.

I want to have email Label and email TextBox at same slot. So I am
setting setVisible true and false for Label or TextBox depending on
which mode I am (edit or read only).

Hope this clear.
> ...
>
> read more »

Taras Petrytsyn

unread,
Jan 29, 2008, 5:24:15 AM1/29/08
to Google-We...@googlegroups.com
Write this way:
<div>
<label id="emailLabel"></label>
<input id="emailText"></input>
<div>

html.addWidget("emailLabel",new Label("Email:"));
html.addWidget("emailText",new TextBox());
2008/1/29, NN <neh...@gmail.com>:

Maksym Markov

unread,
Feb 2, 2008, 5:46:01 PM2/2/08
to Google Web Toolkit
Hi,
It is pretty simple, you just need add two place holders with
different names and add two widgets on the template, so you could
handle visible true/false

html.addWidget("edit1",editText);
html.addWidget("edit2",saveText);

or in your case it will be even more natural to replace widgets
instead of hide/visible

TextBox editText = new TextBox();
Label editLabel = new Label();
editText.setVisible(false);
// add only one widget to form, that you need initially
html.addWidget("edit",saveText);

// editText.setVisible(true);
// saveText.setVisible(false);
// instead of lines above write only one line
html.addWidget("edit",editText); // this will replace widget saveText
with edutText in the same place


// then instead of reverse operation
// editText.setVisible(false);
// saveText.setVisible(true);
// just write
html.addWidget("edit",saveText);


The core issue is misunderstanding - HTMlTemplate REPLACE existing
element with given widget using id.

I can describe why we do so - in our development we use HTML editor
like Dreamweaver or FrontPage for template creation and we need put
some elements like INPUT or DIV to preserv space and have ability to
see real layout within HTML tool. We also needed some holder for
inline styles and css class, so we really needed html element for
replacement. And there is simple rule - one html element is replaced
by one widget ( not by two).
In some previous versions we have two separate methods addWidget and
replaceWidget, but in this release there is only addWidget with
ability overwrite instead of reporting exception "Widget with such id
is already added";
> > > > > > metter, becouseHTMLTemplateWidgetanalyze only id style and class
> > > > > > >HTMLTemplateWidgethtml = newHTMLTemplateWidget("ushow.html");
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages