我的ManagedBean中有一个init函数,它是视图作用域。但是,当页面加载时,我似乎无法运行它 它是这个类中的私人领域
.............
package mike.food;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.JsonMappingException;
@JsonIgnoreProperties(ignoreUnknown = true)
@ManagedBean(name = "nutrition")
@ViewScoped
public class NutritionixResponse implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1016196967087965738L;
private String total_hits;
private String max_score;
private ArrayList<Hits> hits;
private ArrayList<Hits> droppedhits;
public NutritionixResponse() throws JsonParseException, JsonMappingException, IOException {
}
@PostConstruct
public void init() {
this.droppedhits = new ArrayList<Hits>();
}
public String getTotal_hits() {
return total_hits;
}
public void setTotal_hits(String total_hits) {
this.total_hits = total_hits;
}
public String getMax_score() {
return max_score;
}
public void setMax_score(String max_score) {
this.max_score = max_score;
}
public ArrayList<Hits> getHits() {
return hits;
}
public void setHits(ArrayList<Hits> hits) {
this.hits = hits;
}
public ArrayList<Hits> getDroppedhits() {
return droppedhits;
}
public void setDroppedhits(ArrayList<Hits> droppedhits) {
this.droppedhits = droppedhits;
}
}
主要课程
@JsonIgnoreProperties(ignoreUnknown = true)
@Manaents Serializable {
gedBean(name = "FoodClient")
@ViewScoped
public class FoodClient implem
/**
* Need to test something
*/
private static final long serialVersionUID = 3874520453001209544L;
private NutritionixResponse nurition;
和页面
<p:outputPanel id="dropArea">
<p:dataTable id="droppedfoodtable" var="food"
value="#{FoodClient.nurition.droppedhits}"