需要帮助:
我在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();
}
在课堂上使用此方法:
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);
}
结果是一个带有8个标签的Tabview(对应于8个工作表),文本为:&#34; 0&#34;。 但是,我在一个桌面应用程序(没有Web)中尝试了它,结果是一个包含8个条目的String数组,但每个条目中都有相应的文本(不是文本&#34; 0&#34;)。
在网络搜索结果中,我丢失了字符串的内容。 感谢
答案 0 :(得分:1)
使用tabView所有者迭代器而不是c:forEach解决并将其添加到web.xml文件中:
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>