2011-11-22 25 views
0

What i gotExpected我想要使用Primefaces移動與JSF2.0和primefaces-3.0.M2一種形式,但在JBoss服務器部署和瀏覽器上運行它(桌面)後所需要的jar文件,外觀和感覺不是很好。我是否缺少一些jar文件?也有任何模擬器,我可以檢查和運行移動網頁。我現在用的展櫃例如在http://www.primefaces.org/showcase-labs/mobile/index.jsf什麼是運行primefaces移動

+1

首先PrimeFaces移動0.9的正式發佈是由於11月23日與它的用戶指南。它只需要primefaces-mobile.jar和primefaces.jar(現在是RC1-SNAPSHOT)。 Mobile現在是一個單獨的項目。 –

回答

1

如果您的移動/無移動應用程序是分開的,你有你的插入faces-config.xml中的下面一行

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

,如果你的手機/否手機的看法是,你必須

寫相同的應用程序通過重寫calculateRenderKitId API來確定 何時以移動模式顯示頁面。如果您的移動和非移動頁面在同一個應用程序中,並且您需要 即時(從Primefaces移動文檔)切換渲染套件,則建議使用此方法。

這裏有一個簡單的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模擬器,你的應用程序,你可以下載並installate SDK與Android的

  1. 安裝Android SDK
  2. 安裝ADT Eclipse插件
  3. 創建一個Android虛擬設備(AVD)

爲此,請點擊此鏈接:http://developer.android.com/sdk/index.html

然後,按照這個帖子「讓你的Android模擬器來在開發計算機上閱讀虛擬主機」 - http://dillieodigital.wordpress.com/2012/03/19/soup-to-nuts-getting-your-android-emulator-to-read-virtual-hosts-on-your-development-machine/

1

首先,所有你需要的是Primefaces罐子,但自M4版本出來你應該更新您的類路徑(注意,如果你使用的Netbeans,庫中取出它有點馬虎,仔細檢查一下你在lib文件夾中只有一個庫-M4)。

另外,請在這裏發表您的代碼,並要小心使用新的命名空間:

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