JSF抛出异常java.lang.StackOverflowError

时间:2013-12-26 15:22:06

标签: spring jsf

我有一个StackOverflowError我的环境Sping 3.2.0,JSF 2.1.9。

我正在使用带有转换器的OneMenuList,并且在我调试后返回转换器后,我在java.lang.StackOverflowError中遇到了此异常Phases.class

Phases.class:

    try {
        handleBeforePhase(context, listeners, event);
        if (!shouldSkip(context)) {
            execute(context);
        }
    } catch (Throwable e) {
        queueException(context, e);
    }

尝试渲染JSF页面时,我开始收到以下错误。有人有什么想法吗?

转换器:

@Component
@FacesConverter(value = "programmeConverter")
public class ProgrammeConverter implements Converter {

@Autowired
@RmiClient
private IProgrammeService programmeService;

@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
    if (arg2 == null || arg2.isEmpty()) {
        return null;
    }

    String programme = arg2;
    Long value = Long.valueOf(programme);
    ProgrammeDto result = new ProgrammeDto();
    result = programmeService.findById(value);
    return result;
}

@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {

    if (arg2 == null) {
        return "";
    }
    if(arg2 instanceof ProgrammeDto) {
        if (((ProgrammeDto) arg2).getIdProgramme() == null) {
            return "";
        }
    }

    ProgrammeDto programme = new ProgrammeDto();

    if(arg2 instanceof ProgrammeDto) {

        programme = (ProgrammeDto) arg2;
        String codeProgramme = programme.getIdProgramme().toString();
        return (codeProgramme != null) ? String.valueOf(codeProgramme) : null;
    } else throw new ConverterException("Something wrong!" + arg2.hashCode() + arg2.toString());

}
}

Controler:

@Component
@Scope("session")
public class ProgrammeController implements Serializable {

/**
 * 
 */
private static final long serialVersionUID = 2L;


private List<ProgrammeDto> listProgrammes = new ArrayList<ProgrammeDto>();

private ProgrammeDto selectedProgramme = new ProgrammeDto();
private ProgrammeDto programme = new ProgrammeDto();

@Autowired
@RmiClient
private IProgrammeService programmeService;

public String init(){
    actualize();
    return "/views/programme/listeProgramme?faces-redirect=true";
}

public void actualize(){
    selectedProgramme = new ProgrammeDto();
    listProgrammes = programmeService.findAll();
}

public String createDemnade(){
    prepareDtoBeforeSave();
    ProgrammeDto programmeCreatedId = programmeService.create(programme);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("New Tiers Created : " + programmeCreatedId));
    return "/views/programme/newProgramme?faces-redirect=true";
}

protected void prepareDtoBeforeSave() {

}

public void getProgrammeByCode(){

}

/**
 * @return the listProgrammes
 */
public List<ProgrammeDto> getListProgrammes() {
    if (listProgrammes == null) {
        listProgrammes = new ArrayList<ProgrammeDto>();
    }
    return listProgrammes;
}

/**
 * @param listProgrammes the listProgrammes to set
 */
public void setListProgrammes(List<ProgrammeDto> listProgrammes) {
    this.listProgrammes = listProgrammes;
}

/**
 * @return the selectedProgramme
 */
public ProgrammeDto getSelectedProgramme() {
    ProgrammeDto programme = new ProgrammeDto();
    programme = selectedProgramme;
    return programme;
}

/**
 * @param selectedProgramme the selectedProgramme to set
 */
public void setSelectedProgramme(ProgrammeDto selectedProgramme) {
    this.selectedProgramme = selectedProgramme;
}
}

查看:

                <!-- Programme -->
                <p:fieldset legend="Programmes" toggleable="true" toggleSpeed="500"
                    style="margin-left: 10px; margin-top: 30px; background-color:RGB(225,240,233)">

                    <p:commandButton value="Choisir programme" oncomplete="dlg.show()"
                        update="choixProgramme"
                        actionListener="#{programmeController.init}" />

                    <p:dialog header="TMA Programmes" modal="true" showEffect="fade"
                        hideEffect="fade" widgetVar="dlg" width="800px">
                        <p:fieldset legend="Programme" toggleable="true"
                            toggleSpeed="500" style="margin-left: 10px; margin-top: 30px">

                            <h:panelGrid columns="2" cellpadding="10">
                                <h:outputText value="Choisir un programme" />
                                <p:selectOneMenu id="choixProgramme"
                                    converter="#{programmeConverter}"
                                    value="#{programmeController.selectedProgramme}">
                                    <f:selectItem itemLabel="Choisir un programme"
                                        itemValue="#{null}" noSelectionOption="true" />
                                    <f:selectItems value="#{programmeController.listProgrammes}"
                                        var="programme" itemLabel="#{programme.codeProgImmobilier}"
                                        itemValue="#{programme}" />
                                    <p:ajax update="dataTableBien" />
                                </p:selectOneMenu>
                            </h:panelGrid>

                            <p:dataTable id="dataTableBien" var="bien"
                                resizableColumns="true" liveResize="true" paginator="true"
                                value="#{programmeController.selectedProgramme.biens}"
                                rows="10" scrollable="false" style="width: 100%"
                                rowKey="#{bien.idBien}" selectionMode="single"
                                selection="#{demandeController.selectedBien}"
                                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                rowsPerPageTemplate="5,10,15">

                                <p:ajax event="rowSelect" oncomplete="dlg.hide()"
                                    update=":editDemandesForm:programmeShow :editDemandesForm:acquereurShow" />

                                <p:column headerText="N° de Lot" style="width: 100px">
                                    <h:outputText value="#{bien.numLotCommercial}" />
                                </p:column>

                                <p:column headerText="Nom de l'acquéreur" style="width: 100px">
                                    <h:outputText value="#{bien.idAcquereur.nomAcquereur}" />
                                </p:column>


                            </p:dataTable>
                        </p:fieldset>

                    </p:dialog>

                    <h:panelGroup id="programmeShow">
                        <h:panelGrid columns="5" cellpadding="10">
                            <h:outputText value="Programme" style="font-weight:bold" />
                            <h:outputText
                                value="#{demandeController.selectedBien.idProgramme.codeProgImmobilier}" />
                            <h:outputText
                                value="#{demandeController.selectedBien.idProgramme.nomCommercial}" />
                            <h:outputText value="Numéro Lot" style="font-weight:bold" />
                            <h:outputText
                                value="#{demandeController.selectedBien.numLotCommercial}" />
                        </h:panelGrid>
                        <h:panelGrid columns="3" cellpadding="10">
                            <h:outputText value="Nom Juridique" style="font-weight:bold" />
                            <h:outputText
                                value="#{demandeController.selectedBien.idProgramme.formeJuridiqueEntitee}" />
                            <h:outputText
                                value="#{demandeController.selectedBien.idProgramme.nomJuridique}" />
                        </h:panelGrid>
                    </h:panelGroup>

                </p:fieldset>

0 个答案:

没有答案