Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Netbeans 使用Primefaces、Google电子表格API和JSF丢失数据_Netbeans_Jsf 2_Primefaces_Google Spreadsheet Api - Fatal编程技术网

Netbeans 使用Primefaces、Google电子表格API和JSF丢失数据

Netbeans 使用Primefaces、Google电子表格API和JSF丢失数据,netbeans,jsf-2,primefaces,google-spreadsheet-api,Netbeans,Jsf 2,Primefaces,Google Spreadsheet Api,需要帮助: 我在xhtml文件中有以下代码: <h:form id="form"> <p:growl id="msgs" showDetail="true" /> <h3 style="margin-top:0">Comissió</h3> <p:tabView > <p:ajax event="tabChange" listener="#{panelInic

需要帮助:

我在xhtml文件中有以下代码:

<h:form id="form">
        <p:growl id="msgs" showDetail="true" />
        <h3 style="margin-top:0">Comissió</h3>
        <p:tabView >
            <p:ajax event="tabChange" listener="#{panelInicial.onTabChange}" update=":form:msgs"/>
            <p:ajax event="tabClose" listener="#{panelInicial.onTabClose}" update=":form:msgs"/>
            <c:forEach items="#{proceso.nomhojas}" var="item-hoja">
                <p:tab title="#{item-hoja}">
                    <h:panelGrid columns="2" cellpadding="10">
                         <h:outputText
                             value="#{item-hoja}" />
                    </h:panelGrid>
                </p:tab>
            </c:forEach> 
        </p:tabView>
    </h:form>

科米西奥
我有一个类,它的构造函数如下:

@ManagedBean
@SessionScoped
public class Proceso {
    private String USERNAME = "aaaaa@bbb.com";
    private String PASSWORD= "xxxxxxx";
    private SpreadsheetService service= new     SpreadsheetService("MySpreadsheetIntegration-v1");   
    private List<WorksheetEntry> worksheets;   
    private List<SpreadsheetEntry> spreadsheets;
    private SpreadsheetFeed feed;
    private SpreadsheetEntry spreadsheet;
    private URL SPREADSHEET_FEED_URL;
    private String [] Nomhojas;

    public  Proceso()  throws AuthenticationException, MalformedURLException, IOException, ServiceException {
   pruebas();
    }
@ManagedBean
@会议范围
公共类程序{
私有字符串用户名=”aaaaa@bbb.com";
私有字符串密码=“xxxxxxx”;
私人电子表格服务=新的电子表格服务(“MySpreadsheetIntegration-v1”);
私人名单工作表;
私人列表电子表格;
私人电子表格;
私人电子表格输入电子表格;
私有URL电子表格\u提要\u URL;
私有字符串[]nomojas;
public Proceso()引发AuthenticationException、MalformedURLException、IOException、ServiceException{
普鲁巴斯();
}
在类中使用此方法:

public void pruebas () throws AuthenticationException, MalformedURLException, IOException, ServiceException {
   service.setUserCredentials(USERNAME, PASSWORD);

   setSPREADSHEET_FEED_URL(new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full"));    

    setFeed(service.getFeed(SPREADSHEET_FEED_URL, SpreadsheetFeed.class)) ;
    setSpreadsheets(feed.getEntries());

    int a=0;
    setSpreadsheet(spreadsheets.get(a));
    while (!(spreadsheet.getTitle().getPlainText().equals("COMISSIÓ.xlsx"))){
        setSpreadsheet(spreadsheets.get(a++));
    }

    setWorksheets(spreadsheet.getWorksheets()) ;
    Nomhojas = new String[worksheets.size()];
    String [] Nomhojas2 =new String[worksheets.size()];
        //for (WorksheetEntry worksheet : worksheets) {
        for (int i=0;i<Nomhojas.length;i++){
           // Nomhojas.add(worksheet.getTitle().getPlainText());
            Nomhojas2[i]=worksheets.get(i).getTitle().getPlainText();            
        }
        setNomhojas(Nomhojas2);

}
public void pruebas()抛出AuthenticationException、MalformedURLException、IOException、ServiceException{
service.setUserCredentials(用户名、密码);
设置前置页\u提要\u URL(新URL(“https://spreadsheets.google.com/feeds/spreadsheets/private/full"));    
setFeed(service.getFeed(电子表格_FEED_URL,SpreadsheetFeed.class));
setPreadSheets(feed.getEntries());
int a=0;
设置前置表(电子表格.get(a));
而(!(spreadsheet.getTitle().getPlainText().equals(“COMISSIÓ.xlsx”)){
setSpreadsheet(电子表格.get(a++));
}
setWorksheets(电子表格.getWorksheets());
nomojas=新字符串[worksheets.size()];
String[]Nomhojas2=新字符串[worksheets.size()];
//用于(工作表工作表:工作表){

对于(int i=0;i使用tabView所有者迭代器而不是c:forEach求解,并将其添加到web.xml文件:

<context-param>
      <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
      <param-value>true</param-value>   
</context-param>

javax.faces.FACELETS\u跳过\u注释
真的

奇怪的是,它得到了正确数量的工作表,但标题为“0”…呃,不同的主题,您的while循环似乎缺少a++正确、a++修改,谢谢