Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1990

Can't get expected Locale in Bridge

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.5.5
    • 6.5.4
    • ZK Update Engine
    • None
    • None

      following example is just for showing this issue.
      to reproduce.
      1. open a tab link to Render.jsp, you will see console printout a Locale
      2. open another tab, link to Bridge.jsp, you will see null is printed, which is not correct.

      >>locale in Renderers:en_US
      >>locale in Bridge:null
      

      In zss, it count on user's local, Bridge API should also wrap/provide such information.

      Render.jsp

      <%@page import="org.zkoss.util.Locales"%>
      <%@page import="java.util.Locale"%>
      <%@page import="org.zkoss.zk.ui.Page"%>
      <%@page import="org.zkoss.zk.ui.GenericRichlet"%>
      <%@page import="org.zkoss.zkplus.embed.Renders"%>
      <%@page import="java.util.Date"%>
      <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
      <%@taglib prefix="zss" uri="http://www.zkoss.org/jsp/zss"%>
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      	<head>
      	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      	<title>Application for Leave</title>
      	</head>
      <body>
      <%
      
      Renders.render(getServletContext(), request, response, 
      		new GenericRichlet() {
      			public void service(Page page) throws Exception {
      				System.out.println(">>locale in Renderers:"+Locales.getThreadLocal());	
      				page.getDesktop().getSession().setAttribute("testDesktop",page.getDesktop());
      			}
      		}, null, response.getWriter());
      	
      %>
      </body>
      </html>
      

      Bridge.jsp

      <%@page import="org.zkoss.util.Locales"%>
      <%@page import="org.zkoss.zk.ui.Desktop"%>
      <%@page import="org.zkoss.zkplus.embed.Bridge"%>
      <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
      <%@taglib prefix="zss" uri="http://www.zkoss.org/jsp/zss"%>
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      	<head>
      	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      	<title>Application for Leave</title>
      	</head>
      <%
      Desktop desktop = (Desktop)session.getAttribute("testDesktop");
      if(desktop!=null){
      	Bridge zbridge = Bridge.start(getServletContext(), request, response, desktop);
      	try{
      		System.out.println(">>locale in Bridge:"+Locales.getThreadLocal());
      	}finally{
      		zbridge.close();
      	}
      }
      %>
      </html>
      

            jumperchen jumperchen
            dennis dennis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: