我想用f:attribute组件传递参数#{myvar.tc}。在数据表cocukDoktor()方法" dr_tc"来了。我想在参数传输后运行drgor.sayfaYonlendirme()。但是#{myvar.tc}并没有转移。我能做什么?
<h:dataTable value="#{doktor.cocukDoktor()}" var="myvar">
<table>
<tr>
<td>
<h:column>
<h:graphicImage class="doktorfoto" value="resources/images/doktorfoto.jpg"/>
</h:column>
</td>
<td>
<h:column>
<h:form>
<h:commandLink class="doktorismi" action="#{drgor.sayfaYonlendirme()}" actionListener="#{drgor.drtcAyarla}" >#{myvar.dr_adi} #{myvar.dr_soyadi}
<f:attribute name="dr_tc" value="#{myvar.dr_tc}"/>
</h:commandLink>
</h:form>
</h:column>
</td>
</tr>
</table>
</h:dataTable>
Bean代码
@ManagedBean( name="drgor")
@SessionScoped
public class doktorgoruntule {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
String drAdi;
String drSoyadi;
public String getDrAdi() {
return drAdi;
}
public void setDrAdi(String drAdi) {
this.drAdi = drAdi;
}
public String getDrSoyadi() {
return drSoyadi;
}
public void setDrSoyadi(String drSoyadi) {
this.drSoyadi = drSoyadi;
}
public String dr_tc;
public void setDr_tc(String dr_tc) {
this.dr_tc = dr_tc;
}
public String getDr_tc() {
return dr_tc;
}
public void drtcAyarla(ActionEvent event){
dr_tc = (String)event.getComponent().getAttributes().get("dr_tc");
}
public String sayfaYonlendirme(){
return "cocukDoktorGoruntule?faces-redirect=true”";
}
public ResultSet cocukdoktorGoruntule() throws Exception{
try{
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/tipmerkezivt","postgres", "2569");
ps = conn.prepareStatement("select * from doktor \n" +
"WHERE\n" +
"dr_tc = '"+dr_tc+"'" , ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = ps.executeQuery();
return rs;
}
catch (Exception e) {
throw new Exception("Bağlantı başarısız!");
}
finally{
conn.close();
}
}
}
答案 0 :(得分:1)
你可以尝试用
<h:form>
<h:dataTable value="#{doktor.cocukDoktor()}" var="myvar">
<h:column>
<h:graphicImage class="doktorfoto" value="resources/images/doktorfoto.jpg"/>
</h:column>
<h:column>
<h:commandLink class="doktorismi"
action="#{drgor.sayfaYonlendirme()}"
actionListener="#{drgor.drtcAyarla}"
value="#{myvar.dr_adi} #{myvar.dr_soyadi}"
>
<f:setPropertyActionListener target="#{drgor.tr_tc}" value="#{myvar.dr_tc}" />
</h:commandLink>
<h:column>
</h:dataTable>
</h:form>
无论如何,没有必要做表格HTML的东西,它是由dataTable完成的。缺少医生课程可以为您提供更多帮助。要获得更满意的帮助,您需要提供更多信息。