org.zkoss.zk.ui.Desktop.getDeviceType()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.zkoss.zk.ui.Desktop.getDeviceType()方法的一些代码示例,展示了Desktop.getDeviceType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Desktop.getDeviceType()方法的具体详情如下:
包路径:org.zkoss.zk.ui.Desktop
类名称:Desktop
方法名:getDeviceType

Desktop.getDeviceType介绍

[英]Returns the device type that this desktop belongs to.

A device type identifies the type of a client. For example, "ajax" represents the Web browsers with Ajax support, while "mil" represents clients that supports Mobile Interactive markup Language (on Limited Connected Device, such as mobile phones).

A desktop can use the languages belonging to the same device type. See also org.zkoss.zk.ui.metainfo.LanguageDefinition#getDeviceType.

A component can be added to a desktop only if they belong to the same device type.

Default: depends on the extension of the resource path, "ajax" if the path or extension not available. If Richlet is used, its language definition's device type is assumed.
[中]返回此桌面所属的设备类型。
设备类型标识客户端的类型。例如,“ajax”表示支持ajax的Web浏览器,“mil”表示支持移动交互标记语言(在有限的连接设备上,如移动电话上)的客户端。
桌面可以使用属于同一设备类型的语言。另见组织。zkoss。zk。用户界面。元信息。语言定义#获取设备类型。
只有当组件属于同一设备类型时,才能将其添加到桌面。
默认值:取决于资源路径的扩展,如果路径或扩展不可用,“ajax”。如果使用Richlet,则假定其语言定义的设备类型。

代码示例

代码示例来源:origin: org.zkoss.zk/zk

protected void alert(String m) {
  if ("ajax".equals(Executions.getCurrent().getDesktop().getDeviceType())) {
    //zk.jar cannot depends on zul.jar; thus we call Messagebox.show() via
    //reflection.
    try {
      if (_alert == null) {
        final Class<?> mboxcls = Classes.forNameByThread("org.zkoss.zul.Messagebox");
        _alert = mboxcls.getMethod("show", new Class<?>[] { String.class });
      }
      _alert.invoke(null, new Object[] { m });
      return; //done
    } catch (Throwable ex) {
      log.debug("Failed to invoke org.zkoss.zul.Messagebox", ex);
      //Ignore
    }
  }
  org.zkoss.zk.ui.util.Clients.alert(m);
}

代码示例来源:origin: org.zkoss.zk/zk

wapp = desktop.getWebApp();
if (deviceType == null)
  deviceType = desktop != null ? desktop.getDeviceType() : "ajax";

代码示例来源:origin: org.zkoss.zk/zk

wapp = exec.getDesktop().getWebApp();
if (deviceType == null)
  deviceType = exec.getDesktop().getDeviceType();

代码示例来源:origin: org.zkoss.zk/zul

final String errpg = desktop.getWebApp().getConfiguration().getErrorPage(desktop.getDeviceType(), err);
if (errpg != null) {
  try {

代码示例来源:origin: org.zkoss.zk/zk

final Desktop desktop = exec.getDesktop();
final Configuration config = desktop.getWebApp().getConfiguration();
final String location = config.getErrorPage(desktop.getDeviceType(), err);
if (location != null) {
  try {

代码示例来源:origin: org.zkoss.zk/zk

public void setDefinition(String name) {
  final Execution exec = Executions.getCurrent();
  if (exec != null) {
    final ExecutionCtrl execCtrl = (ExecutionCtrl) exec;
    final PageDefinition pgdef = execCtrl.getCurrentPageDefinition();
    final Page page = execCtrl.getCurrentPage();
    ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(name, true)
        : page != null ? page.getComponentDefinition(name, true) : null;
    if (compdef == null)
      compdef = Impls.getDefinitionByDeviceType(this, exec.getDesktop().getDeviceType(), name);
    if (compdef != null) {
      setDefinition(compdef);
      return;
    }
  } else {
    for (String deviceType : LanguageDefinition.getDeviceTypes()) {
      final ComponentDefinition compdef = Impls.getDefinitionByDeviceType(this, deviceType, name);
      if (compdef != null) {
        setDefinition(compdef);
        return;
      }
    }
  }
  throw new ComponentNotFoundException(name + " not found");
}

代码示例来源:origin: org.zkoss.zk/zk

/** Returns the component definition of the specified class, or null
 * if not found.
 */
/*package*/ static ComponentDefinition getDefinition(Execution exec, Class<? extends Component> cls) {
  if (exec != null) {
    final ExecutionCtrl execCtrl = (ExecutionCtrl) exec;
    final PageDefinition pgdef = execCtrl.getCurrentPageDefinition();
    final Page page = execCtrl.getCurrentPage();
    final ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(cls, true)
        : page != null ? page.getComponentDefinition(cls, true) : null;
    if (compdef != null && compdef.getLanguageDefinition() != null)
      return compdef; //already from langdef (not from pgdef)
    final ComponentDefinition compdef2 = Components.getDefinitionByDeviceType(exec.getDesktop().getDeviceType(),
        cls);
    return compdef != null && (compdef2 == null
        || !Objects.equals(compdef.getImplementationClass(), compdef2.getImplementationClass())) ? compdef
            : compdef2; //Feature 2816083: use compdef2 if same class
  }
  for (String deviceType : LanguageDefinition.getDeviceTypes()) {
    final ComponentDefinition compdef = Components.getDefinitionByDeviceType(deviceType, cls);
    if (compdef != null)
      return compdef;
  }
  return null;
}

相关文章