2012-09-30 86 views
0

我有,我想用AJAX標籤使用Primefaces圖表:

<h:head> 

</h:head> 
<h:body> 
    <div id="test" style="width:850px; height:800px; position:absolute; background-color:transparent; "> 

     <h:form> 
      <h:panelGroup layout="block"> 
       <h:selectOneListbox size="0" id="selectedMenu" value="#{dashboardController.selectedMenu}"> 
        <f:selectItem itemLabel="first" itemValue="0" /> 
        <f:selectItem itemLabel="second" itemValue="1" /> 
        <f:selectItem itemLabel="third" itemValue="2" /> 

        <f:ajax event="change" execute="@this" render="loadMenu" /> 
       </h:selectOneListbox> 
      </h:panelGroup> 

      <h:panelGroup layout="block" id="loadMenu"> 
       <h:panelGroup rendered="#{dashboardController.selectedMenu=='0'}"> 
        MENU 0 
       </h:panelGroup> 

       <h:panelGroup rendered="#{dashboardController.selectedMenu=='1'}"> 
        MENU 1 
       </h:panelGroup> 

       <h:panelGroup rendered="#{dashboardController.selectedMenu=='2'}"> 
        MENU 2 
       </h:panelGroup> 
      </h:panelGroup> 
     </h:form>  
    </div> 
</h:body> 


@ManagedBean 
@ViewScoped 
public class DashboardController implements Serializable{ 

private String selectedMenu; 

@PostConstruct 
public void init() { 
    if (selectedMenu == null || selectedMenu.trim().isEmpty()) { 
     this.selectedMenu = "0"; 
    } 
} 

public String getSelectedMenu() { 
    return selectedMenu; 
} 

public void setSelectedMenu(String selectedMenu) { 
    this.selectedMenu = selectedMenu; 
} 
} 

我用這個代碼圖表:

<script type="text/javascript"> 
    $.noConflict(); 
    // Code that uses other library's $ can follow here. 
</script> 
    .......... 

<p:lineChart id="logins" value="#{StatisticsController.weekActivity}" legendPosition="ne" 
           title="Weekly Logins" seriesColors="4D94FF, 1975FF, 005CE6, 0047B2" minY="0" maxY="200"/> 

當我刪除

<script type="text/javascript"> 
    $.noConflict(); 
    // Code that uses other library's $ can follow here. 
</script> 

當AJAX標籤正在工作。看起來$.noConflict();代碼有衝突。我如何解決這個問題?

+0

'jQuery.noConflict();' – Ohgodwhy

+0

這不解決問題。 – user1285928

+0

什麼樣的衝突?你在使用其他使用'$'的庫嗎? – undefined

回答

2

因此,從primefaces庫中刪除jquery包含,並讓它使用已包含的jQuery。

+0

你能否給我一些更多的信息如何做到這一點。我測試了這個解決方案,但它不起作用:http://forum.primefaces.org/viewtopic.php?f=3&t=18685,http://stackoverflow.com/questions/11112058/how-to-use-jquery-with -primefaces – user1285928