- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2015 04:12 AM
Hello Gurus,
I`ve created custom macros, which I want to initiate/call from within other macros or UI pages. However, one thing I am not sure about is "the phase" in which a nested macro should be initiated.. Should i be using <g or <g2 instead ? What is the best/recommended practice on this ?
thanks a lot for your help
Cheers
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2015 12:14 AM
Here goes the examples that probes the statement on the prior post:
Given a simple macro like the following:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var='jvar_now'>
gs.nowNoTZ();
</g:evaluate>
This macro current Date is: <input id="id_test" value='${jvar_now}' />
</j:jelly>
1 - In a form: The results are cached when used from a form. I reloaded the below form multiple times and the time displayed never changed.
2- In a UI Page: The results are NOT cached when used in a UI page. The time will change every time i reloaded a UI page from which I'm invoking the macro:
3- In a MOBILE view: The results are NOT cached. The time will change every time I reloaded the macro using the view path for mobile
So, having reviewed our examples, you should only use g1 when your results can be cached and been aware that these would not be cached if used from a UI Page or from a Mobile View.
I really hope this was helpful. I enjoyed building the example on the various views... so thanks for asking the follow up question!
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2015 07:43 AM
Berny,
thanks for your reply. Very appreciated.
One more question for you... When would you use g versus g2 statements ? some examples would help a lot..
Kind Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2015 12:05 AM
Hi Maros, you're welcome! kudos to you for such a great follow up question...
First, lets review what the wiki states:
3 Phases
Usually, there are two phases indicated by namespaces <j> versus <j2> and <g> versus <g2>. The namespaces without the "2" happen in the first phase of processing and these are cached except when used in a UI page. Those with the "2" are never cached. Care must be taken when selecting whether to use phase 1 or phase 2 for efficiency and correct results.
That one in the wiki is a great guideline since we learn the following:
a) phase 1 is cached
b) EXCEPT when used in a UI page!
Yet, it's incomplete since that Exception should include looking to the macro from a Mobile view. I'll soon share the examples that demonstrates each case in a following post.
So... before jumping to the examples, lets jump directly to the conclusion:
You should use g versus g2...
a) when your results can be cached
b) when your macro is not rendering quick enough and you have opportunities to cache part of it to improve it's performance.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2015 12:14 AM
Here goes the examples that probes the statement on the prior post:
Given a simple macro like the following:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var='jvar_now'>
gs.nowNoTZ();
</g:evaluate>
This macro current Date is: <input id="id_test" value='${jvar_now}' />
</j:jelly>
1 - In a form: The results are cached when used from a form. I reloaded the below form multiple times and the time displayed never changed.
2- In a UI Page: The results are NOT cached when used in a UI page. The time will change every time i reloaded a UI page from which I'm invoking the macro:
3- In a MOBILE view: The results are NOT cached. The time will change every time I reloaded the macro using the view path for mobile
So, having reviewed our examples, you should only use g1 when your results can be cached and been aware that these would not be cached if used from a UI Page or from a Mobile View.
I really hope this was helpful. I enjoyed building the example on the various views... so thanks for asking the follow up question!
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2015 01:15 AM
berny,
thanks a lot for your help. I closed this thread by marking one of your replies correct..
cheers
Maros