运行 primefaces mobile 所需的 jar 文件是什么

发布于 2024-12-17 08:22:15 字数 413 浏览 3 评论 0原文

我得到了什么预期我想使用带有jsf2.0和primefaces-3.0.M2的Primefaces Mobile制作一个表单,但是在jboss服务器中部署并在浏览器(桌面)上运行后,外观和感觉并不那么好 伟大的。我是否缺少一些 jar 文件?还有没有模拟器可以让我检查和运行移动网页。我正在使用展示示例 http://www.primefaces.org/showcase -labs/mobile/index.jsf

What i gotExpectedI want to make a form using Primefaces Mobile with jsf2.0 and primefaces-3.0.M2, but after deploying in jboss server and running it on browser(desktop), the look and feel is not so great. Am i missing some jar files?? Also is there any emulator where i can check and run the mobile webpages. I am using the showcase example at http://www.primefaces.org/showcase-labs/mobile/index.jsf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧伤还要旧人安 2024-12-24 08:22:15

如果您的移动/非移动应用程序是分开的,则必须在 faces-config.xml 中插入以下行(

<application>
    <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id>
</application>

如果您的移动/非移动视图位于同一应用程序中),则必须

通过重写calculateRenderKitId API编写一个视图处理程序并决定
何时以移动模式显示页面。如果出现以下情况,建议采用此方法
您的移动页面和非移动页面位于同一应用程序中,并且您需要
动态切换渲染套件(来自 Primefaces Mobile 文档)。

这里是一个简单的 ViewHandler 类,它使用 Spring Mobile 功能在移动和非移动页面之间切换。

import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.mobile.device.Device;
import org.springframework.mobile.device.DeviceUtils;
import org.springframework.mobile.device.site.SitePreference;
import org.springframework.mobile.device.site.SitePreferenceUtils;

/**
 * @author <a href="mailto:gesuino.napoli">Gesuino Napoli</a>
 *
 */
public class MobileViewHandler extends ViewHandlerWrapper {

    private ViewHandler wrapped;

    public MobileViewHandler(ViewHandler wrapped) {
    this.wrapped = wrapped;
    }

    @Override
    public ViewHandler getWrapped() {
        return this.wrapped;
    }

    @Override
    public String calculateRenderKitId(FacesContext context) {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        Device device = DeviceUtils.getRequiredCurrentDevice(request);
        SitePreference sitePreference = SitePreferenceUtils.getCurrentSitePreference(request);
        if (device.isMobile() || sitePreference == SitePreference.MOBILE) {
            return "PRIMEFACES_MOBILE";
        }
        return this.wrapped.calculateRenderKitId(context);
    }
}

然后将 ViewHandler 注册到 faces-config.xml

<application>
        <!-- <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id> -->
        <view-handler>com.acme.myproject.web.util.viewhandler.MobileViewHandler</view-handler>
....
</application>

如果您想使用 Android 模拟器测试您的应用程序,您可以下载并安装 sdk-android

  1. 安装 Android SDK
  2. 安装 ADT Eclipse 插件
  3. 创建 Android 虚拟设备 (AVD)

要执行此操作,请执行以下操作此链接:http://developer.android.com/sdk/index.html

然后,按照这篇文章“让您的 Android 模拟器读取开发计算机上的虚拟主机” -

If your mobile/no mobile applications are separated, you have to insert in your faces-config.xml the following line

<application>
    <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id>
</application>

if your mobile/no mobile views are in the same application you have to

write a viewhandler by overriding calculateRenderKitId API and decide
when to display the page in mobile mode. This approach is suggested if
your mobile and non-mobile pages are in same application and you need
to switch renderkits on-the-fly (from Primefaces Mobile Documentation).

Here a simple ViewHandler class that uses the Spring Mobile functionalities to switch between mobile and non-mobile pages.

import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.mobile.device.Device;
import org.springframework.mobile.device.DeviceUtils;
import org.springframework.mobile.device.site.SitePreference;
import org.springframework.mobile.device.site.SitePreferenceUtils;

/**
 * @author <a href="mailto:gesuino.napoli">Gesuino Napoli</a>
 *
 */
public class MobileViewHandler extends ViewHandlerWrapper {

    private ViewHandler wrapped;

    public MobileViewHandler(ViewHandler wrapped) {
    this.wrapped = wrapped;
    }

    @Override
    public ViewHandler getWrapped() {
        return this.wrapped;
    }

    @Override
    public String calculateRenderKitId(FacesContext context) {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        Device device = DeviceUtils.getRequiredCurrentDevice(request);
        SitePreference sitePreference = SitePreferenceUtils.getCurrentSitePreference(request);
        if (device.isMobile() || sitePreference == SitePreference.MOBILE) {
            return "PRIMEFACES_MOBILE";
        }
        return this.wrapped.calculateRenderKitId(context);
    }
}

Then register the ViewHandler into the faces-config.xml

<application>
        <!-- <default-render-kit-id>PRIMEFACES_MOBILE</default-render-kit-id> -->
        <view-handler>com.acme.myproject.web.util.viewhandler.MobileViewHandler</view-handler>
....
</application>

If you want to test your application with an android emulator you can download and installate the sdk-android

  1. Install Android SDK
  2. Install ADT Eclipse plugin
  3. Create an Android Virtual Device (AVD)

To do this follow this link: http://developer.android.com/sdk/index.html.

Then, follow this post to "Getting Your Android Emulator to Read Virtual Hosts on your Development Machine" - http://dillieodigital.wordpress.com/2012/03/19/soup-to-nuts-getting-your-android-emulator-to-read-virtual-hosts-on-your-development-machine/

栀梦 2024-12-24 08:22:15

首先,您需要的只是 Primefaces jar,但由于 M4 版本已经发布,您应该更新您的类路径(请注意,如果您使用 Netbeans,删除它的库是一个有点马虎,请仔细检查一下 lib 文件夹中是否只有一个库 - M4)。

另外,请在此处发布您的代码,并小心使用新的命名空间:

xmlns:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile"

Firstly, all you need is the Primefaces jar, but since the M4 version is out you should update your classpath(be careful that if you use Netbeans, the library removing it's a little sloppy, double check that you have only one library-M4 in the lib folder).

Also, please post your code here, and be careful to use the new namespaces:

xmlns:p="http://primefaces.org/ui"
xmlns:pm="http://primefaces.org/mobile"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文