New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy portlet: property to disable namespace mapping #2764

Closed
ebruchez opened this Issue May 9, 2016 · 4 comments

Comments

Projects
None yet
1 participant
@ebruchez
Collaborator

ebruchez commented May 9, 2016

The original rationale was to reduce page size, back in the days of IE 7. But that might be of little consequence nowadays, with gzipped pages and faster rendering engines.

Further, this might cause issues in load-balanced servers in some configurations, although that is unclear exactly how yet.

Still, we suggest adding this property and later to remove the namespace mapping if needed.

+1 from customer

@ebruchez ebruchez self-assigned this May 9, 2016

@ebruchez ebruchez added this to the 2016.2 milestone May 9, 2016

@ebruchez ebruchez added the Embedding label May 9, 2016

@ebruchez

This comment has been minimized.

Show comment
Hide comment
@ebruchez

ebruchez May 9, 2016

Collaborator

How this works with proxy portlet:

  • A view request arrives (to show a form)
  • The portlet's long namespace is obtained from the portlet API
  • We obtain from the portlet context a mapping "long namespace" → "short namespace"
  • If a mapping already exists, we use it, otherwise, we create it and store it. The "short namespace" is for example o0. Further prefixes are o1, etc.
  • The form body goes through rewriting with APISupport.writeResponseBody()
    • URLs go through LiferayURL.wsrpToPortletURL()
    • for resources like CSS, this creates a ResourceURL pointing to the portlet
  • When a request for a CSS resources comes in to the portlet:
    • it is sent to Form Runner without an ns= URL parameter
    • so XFormsResourceServer uses wsrp_rewrite_
    • , which returns CSS with encoded prefixes like #wsrp_rewrite_xforms-form.
  • When the CSS is received by the proxy portlet from Form Runner, it again uses the mapping "long namespace" → "short namespace" to replace the wsrp_rewrite_ strings in the returned CSS.

The whole thing depends on the fact that the HTML and the CSS reach the same portlet (by portlet id) on the same Liferay.

Collaborator

ebruchez commented May 9, 2016

How this works with proxy portlet:

  • A view request arrives (to show a form)
  • The portlet's long namespace is obtained from the portlet API
  • We obtain from the portlet context a mapping "long namespace" → "short namespace"
  • If a mapping already exists, we use it, otherwise, we create it and store it. The "short namespace" is for example o0. Further prefixes are o1, etc.
  • The form body goes through rewriting with APISupport.writeResponseBody()
    • URLs go through LiferayURL.wsrpToPortletURL()
    • for resources like CSS, this creates a ResourceURL pointing to the portlet
  • When a request for a CSS resources comes in to the portlet:
    • it is sent to Form Runner without an ns= URL parameter
    • so XFormsResourceServer uses wsrp_rewrite_
    • , which returns CSS with encoded prefixes like #wsrp_rewrite_xforms-form.
  • When the CSS is received by the proxy portlet from Form Runner, it again uses the mapping "long namespace" → "short namespace" to replace the wsrp_rewrite_ strings in the returned CSS.

The whole thing depends on the fact that the HTML and the CSS reach the same portlet (by portlet id) on the same Liferay.

@ebruchez

This comment has been minimized.

Show comment
Hide comment
@ebruchez

ebruchez May 9, 2016

Collaborator

With server-side embedding:

  • The form body goes through rewriting with APISupport.writeResponseBody()
    • CSS URLs are rewritten as $contextPath/$orbeonPrefix/$namespace$resourceId where $resourceId includes an initial /
    • $namespace is o0, etc. produced in sequence of embedding in the page
    • the namespace information is not persisted beyond the request which loads the page because that's not useful
  • Incoming CSS URL is forwarded to Form Runner
    • namespace is received as part of the URL
    • we don't use an ns= parameter either!
    • namespace is used to rewrite wsrp_rewrite_ in content

In short: in this case, things are stateless, unlike in the case of the proxy portlet.

Collaborator

ebruchez commented May 9, 2016

With server-side embedding:

  • The form body goes through rewriting with APISupport.writeResponseBody()
    • CSS URLs are rewritten as $contextPath/$orbeonPrefix/$namespace$resourceId where $resourceId includes an initial /
    • $namespace is o0, etc. produced in sequence of embedding in the page
    • the namespace information is not persisted beyond the request which loads the page because that's not useful
  • Incoming CSS URL is forwarded to Form Runner
    • namespace is received as part of the URL
    • we don't use an ns= parameter either!
    • namespace is used to rewrite wsrp_rewrite_ in content

In short: in this case, things are stateless, unlike in the case of the proxy portlet.

@ebruchez

This comment has been minimized.

Show comment
Hide comment
@ebruchez

ebruchez May 9, 2016

Collaborator

For reference, here is an example of Liferay-generated id:

_orbeonformsproxyportlet_WAR_orbeon20161201605091928proxyportlet_INSTANCE_WG1TSDnV9GhP_

It is 87 character long. I have about 500 of those in a fairly small form, which amounts to about 42 KB more than the version with short prefixes! Gzipped it doesn't make a difference, luckily.

Collaborator

ebruchez commented May 9, 2016

For reference, here is an example of Liferay-generated id:

_orbeonformsproxyportlet_WAR_orbeon20161201605091928proxyportlet_INSTANCE_WG1TSDnV9GhP_

It is 87 character long. I have about 500 of those in a fairly small form, which amounts to about 42 KB more than the version with short prefixes! Gzipped it doesn't make a difference, luckily.

@ebruchez ebruchez changed the title from Property to disable namespace mapping to Proxy portlet: property to disable namespace mapping May 9, 2016

@ebruchez ebruchez closed this May 9, 2016

@ebruchez

This comment has been minimized.

Show comment
Hide comment
@ebruchez
Collaborator

ebruchez commented Aug 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment