View Javadoc

1   /***
2    * 
3    */
4   package net.sourceforge.jdbdump.gui;
5   
6   import java.io.IOException;
7   
8   import javax.faces.component.html.HtmlDataTable;
9   import javax.faces.context.FacesContext;
10  import javax.faces.el.ValueBinding;
11  
12  import net.sourceforge.jdbdump.connect.Configuration;
13  import net.sourceforge.jdbdump.connect.DatabaseConnectionData;
14  
15  /***
16   * @author grabka
17   *
18   */
19  public class TabDbListBean {
20  	private HtmlDataTable dataTable;
21  
22  	public HtmlDataTable getDataTable() {
23  		return dataTable;
24  	}
25  
26  	public void setDataTable(HtmlDataTable dataTable) {
27  		this.dataTable = dataTable;
28  	}
29  	
30  	public String newButtonAction() {
31  		return "dbAdd";
32  	}
33  	
34  	public String editLinkAction() {
35  		DatabaseConnectionData data = (DatabaseConnectionData) this.getDataTable().getRowData();
36  		FacesContext ctx = FacesContext.getCurrentInstance();
37  		
38  		/* copying values from data to bean */ 
39  		DbEditBean editData = new DbEditBean();
40  		editData.setDbName(data.getDatabaseName());
41  		editData.setDbServerName(data.getServer());
42  		editData.setDbTitle(data.getTitle());
43  		editData.setEngine(data.getDatabaseType());
44  		editData.setLogin(data.getLogin());
45  		editData.setPassword(data.getPassword());
46  		editData.setPasswordAgain(data.getPassword());
47  		editData.setPort(data.getPort());
48  		editData.setUrl(data.getURL());
49  		
50  		ValueBinding binding = ctx.getApplication().createValueBinding("#{dbEditBean}");
51  		binding.setValue(ctx, editData);
52  		return "dbEdit";
53  	}
54  	
55  	public String deleteLinkAction() throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
56  		DatabaseConnectionData data = (DatabaseConnectionData) this.getDataTable().getRowData();
57  		
58  		Configuration.getInstance().removeDatabase(data);
59  		
60  		return "infoRmDb";
61  	}
62  }