我有JSF頁面。我的目標是通過從數據庫獲取模式來動態構建驗證器。validateregex的動態模式不起作用,但靜態版本是
我的代碼下面不能正常工作。我的意思是正則表達式失敗。
<p:inputText value="#{basvuruBean.basvuru.sistem.tavsiyeEdilenID}"
requiredMessage="Lütfen Tavsiye Edilen ID giriniz"
validatorMessage="#{basvuruBean.basvuru.sistem.tavsiyeEdilenIDHataMesaji}"
rendered="#{basvuruBean.basvuru.sistem.tavsiyeEdilenIDRendered}">
<f:validateRegex pattern="#{basvuruBean.basvuru.sistem.tavsiyeEdilenIDRegEX}" />
</p:inputText>
,但這個工作如預期
<p:inputText value="#{basvuruBean.basvuru.sistem.tavsiyeEdilenID}"
requiredMessage="Lütfen Tavsiye Edilen ID giriniz"
validatorMessage="#{basvuruBean.basvuru.sistem.tavsiyeEdilenIDHataMesaji}"
rendered="#{basvuruBean.basvuru.sistem.tavsiyeEdilenIDRendered}">
<f:validateRegex pattern="\d" />
</p:inputText>
basvuruBean.basvuru.sistem.tavsiyeEdilenIDRegEX
等於\d
。我通過在JSF頁面上打印來檢查它。
我必須做些什麼才能使它工作?
支持bean的相關部分
import java.io.IOException;
import com.itextpdf.text.DocumentException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.FlowEvent;
@ManagedBean
@ViewScoped
public class BasvuruBean implements Serializable {
private Basvuru basvuru = new Basvuru();
private Sistem sistem;
private static final long serialVersionUID = 1L;
private String url;
private List<Sistem> sistemler = new ArrayList<Sistem>();
private SistemDAO sistemDAO = new SistemDAO();
@PostConstruct
void initialiseSession() {
FacesContext.getCurrentInstance().getExternalContext().getSession(true);
sistem=sistemler.get(0);
}
public BasvuruBean() {
sistemler = sistemDAO.tumSistemler();
this.basvuru.setSistem(sistem);
this.basvuru.setSirketAdi("Şirket Adı");
this.basvuru.setePosta("[email protected]");
}
public void sistemChangeListener() {
System.out.println(sistem.getSistemAdi());
sistem.setKapsamaYaricapi(this.sistem.getKapsamaYaricapiDefault());
this.sistem.setKapsamaYuksekligi(this.sistem.getKapsamaYuksekligiDefault());
this.sistem.setFrekansMax(this.sistem.getFrekansMaxDefault());
this.sistem.setFrekansMin(this.sistem.getFrekansMinDefault());
this.sistem.setTavsiyeEdilenID(this.sistem.getTavsiyeEdilenIDDefault());
this.sistem.setRunway(this.sistem.getRunwayDefault());
this.sistem.setTrueRadiationDirection(this.sistem.getTrueRadiationDirectionDefault());
this.sistem.setApproachCAT(this.sistem.getApproachCATDefault());
this.sistem.setAntenVericiGucuDefault(this.sistem.getAntenVericiGucuDefault());
this.sistem.setAntenYuksekligiAGL(this.sistem.getAntenYuksekligiAGLDefault());
this.sistem.setFrekans(this.sistem.getFrekansDefault());
}
}
和selectOneMenu用於哪些改變SISTEM對象
<p:selectOneMenu value="#{basvuruBean.basvuru.sistem}" converter="sistemConverter">
<f:selectItems value="#{basvuruBean.sistemler}" var="s" itemLabel="#{s.sistemAdi}" itemValue="#{s}" />
<p:ajax listener="#{basvuruBean.sistemChangeListener}" update="p2 genelbilgi" />
</p:selectOneMenu>
你能向我們展示你的支持bean嗎?至少它的所有相關部分。 – partlov 2013-03-08 20:35:07
我已經添加了一些更多的代碼部分 – nsumer 2013-03-08 20:44:13