0

UiFactory, GUI and Data from DB,caching...

asked 2007-01-29 20:44:05 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4128065

By: oberinspector

hello,

As proposed by tom in an earlier post i want to extend UiFactory and overwrite
getPagedefinition(...) to retrieve the page content (GUI and Data) from cache or from DB.

How can i create a PageDefinition from a ZUL-XML String like:
<vbox>
<hbox>
<window id=logo>logo...</window>
<window id=box_top hight=200px/>
</hbox>
<hbox hight=100%>
<vbox id=box_menu width=150px>
<window id=box_mainmenu/>
<window id=box_usermenu/>
</vbox>
<window id=box_mainwidth=100%/>
<vbox width=200px>
<window id=box_maininfo/>
<window id=box_userinfo/>
</vbox>
</hbox>
<window id=box_bottom hight=100px/>
</vbox>

Is there something like the createComponentsDirectly(String fromDB) also to create PageDefinition?
This first ZUL String builds up my website layout and defines overwriteable content areas. Is it possible to take the PageDefinition and overwrite the defined content windows (id=box_*) also with ZUL strings from DB?
The content areas are overwritten in several stages, dependent on the parts of the URL. When ready, the created and overwritten PageDefinitions should be cached for the requested URL and will be returned by the UiFactory.
Is the UiFactory still the right place to do this?

Thank for your help!

regards,
Thomas


Backround:

I'm working on a project which handles multiple websites respectively iframes
in the same database and with one ZK web application. Accordingly DNS and Tomcat
is configured to delegate the request for different domains to one ZK web
application. The websites might have different layouts and styles, but can share
the same data.

I'm working on a general layout mechanism for ZK. Data AND GUI are stored in
a database V no .zul files are used. For the layout mechanism i have a set
of related database objects:

- A design object, which stores a layout and a corresponding CSS.
- A website object, which holds a Java map of content assignments for the different
layout areas
- optional subsite objects, which can overwrite assignments of dedicated content
areas of the website
- GUI-data usecases, which define the presentation of data objects in dedicated
content areas... realized with ZK components and data binding.

A website object has at least one default design object, which stores
a CSS string and a ZUL-XML layout string... e.g. something like the above shown
ZUL-XML...
This example has empty content windows, but a web designer could fill in example
data to get an idea of the design (Later the content areas will be overwritten
by website and GUI-data usecases... Some areas, like logo and graphical layout
elements must not be overwritten...).

When a request for a website (say example.com) has to be rendered, the corresponding
website object is retrieved from DB and a PageDefinition is created from the
default layout. Afterwards the content areas (named box_*) are overwritten
with the websites content assignments, which are also ZUL-XML strings stored
in the database. A subset of this content areas are provided for hierarchical
lower subsites in a Java map and might also be overwritten later. So when a
subsite sub1 is requested (e.g. when a URL http://sub1.example.com or
http://example.com/sub1 is called), the subsite can overwrite the provided content
areas with content from DB stored ZUL-XML strings and can again provide a subset
of content areas to hierarchical lower URL parts like subsite sub2 e.g.
when URL http://sub1.example.com/sub2/.../... or http://example.com/sub1/sub2/.../...
is called.

Last but not least a GUI data usecase can overwrite again dedicated content
areas with data content. A data object data1 could could be viewed with
http://example.com/sub1/sub2/data1?uc=view or edited with
http://example.com/sub1/sub2/data1?uc=edit .

As i understand the idea of PageDefiniton this is an internal representation
of the ZUL files, which build up a page, but probably has not yet a view in
the clients web browser... and can be cached...

I'm thinking of an data structure PageDefinitionMap, which provides a Pagedefinition
with getPageDefinition() and a OverwritableContentAreas Map with MAP <String,
Pagedefinition> getOverwriteableContentAreas(...). This data structure will
be created for a URL as described above and will be cached with the URL as key.
On the other hand i want to have a cachable data structure, which holds a map
of content assignments, which can be used to overwrite the OverwritableContentAreas
of PageDefinitionMap.

To render a request like for URL http://example.com/sub1/sub2/data1?uc=view
first the website/subsite part of the URL is separated from the data part:
example.com/sub1/sub2 and the UiFactory queries the cache for this. When not
found for example.com/sub1 and then for example.com. When no cache entry is
found the corresponding website object is retrieved from DB, a PageDefinitionMap
is created from the layout and from the content assignment and is cached under
example.com as cache key. Other URL subsite and data parts are also retrieved
from DB or cache, content areas are oberwritten in the PageDefinitionMap, which
is cached again... When the website, subsite and data parts of the whole URL
is retrieved, the complete PageDefinition is returned from the UiFactory.



delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2007-01-30 04:15:37 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4128535

By: tomyeh

Hi Thomas,

You owed me a small talk about loading UI from database:)

First of all, you can use getPageDefinitionDirectly (of AbstractUiFactory) to parse the content you loaded from DB. In the latest codes (1/30), you can change id, title and style after page definition is parsed and generated.

If taglib and so are loaded from DB (at least other than Web resources), you have to provide an implementation of org.zkoss.util.resource.Locator (and call RequestInfo.setLocator to changeg it).

Yes, UiFactory is the right place but, as you process further, we might have to adjust something to make it more convenient to code. Note: it is suggested to derive from AbstractUiFactory and provide the implementation of getPageDefinition.
You don't have to override getPageDefinitionDirectly.

AbstractUiFactory doesn't provide a default cache mechanism, so you have to implement one. It is easy by use of org.zkoss.web.util.resource.ResourceCaches.
Refer to org.zkoss.zk.ui.metainfo.PageDefinitions for example.

/Tom



link publish delete flag offensive edit

answered 2007-01-30 09:00:16 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4128737

By: oberinspector

hi tom,

yes... i promised that... long time ago... i had some redesign work in my db...
hopefully i will now get further with the UiFactory... the little longer backround explanation is probably the beginning of the smalltalk... ;)

Thanks a lot for your answer!

/Thomas

link publish delete flag offensive edit

answered 2007-01-30 09:12:12 +0800

admin gravatar image admin
18691 1 10 130
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4128757

By: tomyeh

You are welcome.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2007-01-29 20:44:05 +0800

Seen: 473 times

Last updated: Jan 30 '07

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More