Florent Guillaume wrote:
> Negociation engines are designed to answer exactly this kind of problem.
> Also see http://jira.nuxeo.org/browse/NXP-1367 which had a similar
> question.
>
> Florent
>
Yes, it is rather easy to implement. For instance, the LocalTheme
negotiation scheme which is specific to nuxeo webapp was added on top of
the default modules found in nxthemes.
you'd create a new negotiation scheme:
import org.nuxeo.theme.negotiation.Scheme;
public final class MobileDevice implements Scheme {
public String getOutcome(final Object context) {
Map<String, String> headerMap = ((FacesContext)
context).getExternalContext().getRequestHeaderMap();
// handle the information found in the request (navigator,
accept, ...)
if (...) {
return "mobile-device";
}
return null;
}
}
Then you should add the module in your theme-contrib.xml under
<negotiation object="theme" strategy="nuxeo5">. It will overwrite the
existing one.
The only issue is to choose the order in which the negotiation modules
will be called. Usually the first modules are the ones that handle
explicit information (request parameters, cookies), the last ones are
the fallback modules.
<negotiation object="theme" strategy="nuxeo5">
<scheme>org.nuxeo.theme.jsf.negotiation.theme.RequestParameter</scheme>
<scheme>org.nuxeo.theme.jsf.negotiation.theme.CookieValue</scheme>
<scheme>org.nuxeo.theme.jsf.negotiation.theme.ViewId</scheme>
<!-- local theme (specific to nuxeo5) -->
<scheme>org.nuxeo.ecm.webapp.theme.negotiation.LocalTheme</scheme>
<!-- Mobile devices -->
<scheme>......theme.negotiation.MobileDevice</scheme>
<scheme>org.nuxeo.theme.jsf.negotiation.theme.DefaultTheme</scheme>
</negotiation>
/JM
> On 9 Jan 2008, at 22:30, Carlos Vela wrote:
>
>> Mobile Devices uses HTTP headers like:
>> -Content-Type: application/xhtml+xml
>> -User-Agent:Mozilla/5.0
>> -Accept:application/xhtml+xml,text/css,text/vnd.nokia.rs-tgd,
>> */*,text/x-hdml,image/mng,image/x-mng,video/mng,video/x-mng,image/bmp
>>
>> More insteresting for my purposes are Content-Type and Accept.
>>
>> Media attribute would depend on browser, and I would like to try HTTP
>> headers way first.
>>
>> So, can it be done with negotiation engines? or has to be harcoded?
>> (where
>> exactly in last case)
>>
>> Thanks for your good and quick response.
>> ----- Original Message ----- From: "Olivier Grisel" <[EMAIL PROTECTED]>
>> To: <[email protected]>
>> Sent: Wednesday, January 09, 2008 9:18 PM
>> Subject: [Ecm] Re: Diferent Theme for diferent client
>>
>>
>>> Carlos_Informatica La Reina a écrit :
>>>> Hi all!
>>>>
>>>> I want Nuxeo uses a theme for PC and other theme for Mobile Devices.
>>>>
>>>> It must be computed with "negotiation". But not found
>>>> documentation. It
>>>> seems to be around
>>>> org.nuxeo.theme/nuxeo-theme-jsf/src/main/java/org/nuxeo/theme/jsf/negotiation
>>>>
>>>> and don't know what to do.
>>>>
>>>> A second target: Can I select a default theme in a diferent way that
>>>> changing in theme-contrib.xml?
>>>>
>>>> Any help?
>>>
>>> Currently implemented negociation engines either used cookies, query
>>> parameters
>>> (e.g. http://my_nuxeo_url?theme=theme_id/page_id ), JSF view ids or
>>> the placeful
>>> service and hence are probably useless to discriminate between a
>>> mobile browser
>>> and a full blown browser.
>>>
>>> Do you know what info mobile browser give in their HTTP request to
>>> introduce
>>> them selves as such to the HTTP server? Maybe those browser would
>>> use a CSS
>>> declared special "media" attribute in the page headers?
>>>
>>> --
>>> Olivier
>> -----------
>> Carlos Vela
>> Dpto I+D.
>> Yerbabuena Software.
>> [EMAIL PROTECTED]
>> http://www.yerbabuena.es
>> Tlf/Fax: 902 995 246
>>
>>
>> _______________________________________________
>> ECM mailing list
>> [email protected]
>> http://lists.nuxeo.com/mailman/listinfo/ecm
>>
>
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm