Java - Como llamar a una metodo desde otra clase

 
Vista:
sin imagen de perfil

Como llamar a una metodo desde otra clase

Publicado por Eduardo (1 intervención) el 11/01/2014 23:37:55
HOLA AMIGOS SOY NUEVO EN ESTO DE LA PROGRAMACION, ESPERO ME PUEDAN AYUDAR...
TENGO DOS CLASES PRINCIPALES.
CTRLREPORTE E IMPRIMIRFOJA

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
**************************
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package windows;
 
import dao.PublicoSingleton;
import dao.personasDAO;
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Window;
import dao.genericoDAO;
import org.springframework.jdbc.core.JdbcTemplate;
 
 
/**
 *
 * @author A101
 */
public class CtrlReportesWnd extends Window{
 
 
    Listbox lista;
    protected personasDAO currentPersonas;
    genericoDAO g = new genericoDAO();
    PublicoSingleton s = g.getPublicoSingleton();
 
    public void onCreate(){
        lista=(Listbox)this.getFellow("lista");
        currentPersonas = new personasDAO();
        currentPersonas.setJdbcTemplate(s.getJdbcTemplate());
 
        MostrarSeleccionado();
    }
 
 
    public void MostrarSeleccionado(){
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy");
    DecimalFormat df = new DecimalFormat("##0.000");
 
        currentPersonas.setCip(s.getCUSUARIO_CODIGO());
        List lt = currentPersonas.Ctrl_Reporte(s.getCUSUARIO_CODIGO());
        lista.getItems().clear();
        for(Iterator it = lt.iterator();it.hasNext();){
            personasDAO i = (personasDAO) it.next();
            Listitem item = new Listitem();
            String j = (String)i.getCip();
            item.setValue(j);
            item.appendChild(new Listcell((i.getGrado())));
             item.appendChild(new Listcell((i.getNombres())));
            item.appendChild(new Listcell((i.getMenu())));
            item.appendChild(new Listcell((i.getIdentifica())));
            item.appendChild(new Listcell(sdf.format(i.getInicio())));
 
            lista.appendChild(item);
        }
 
}
 
 
}





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
*********************
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package windows;
 
import dao.PublicoSingleton;
import dao.cambiosDAO;
import dao.genericoDAO;
import dao.personasDAO;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zkex.zul.Jasperreport;
import org.zkoss.zul.*;
 
/**
 *
 * @author eduard
 */
public class ImprimirFojaServicios extends Window{
 
public void imprimir() throws Exception{
 
try {
 
    String DATE_FORMAT = "dd/MM/yyyy";
    String  strFecha = "";
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
 
    ireport.setWidth("100%");
    ireport.setHeight("100%");
 
      //Window win = new Window(getReportTitle(), "normal", true);
    Window win = new Window(this.getTitle(), "normal", true);
            win.setPosition("center");
            win.setWidth("50%");
            win.setHeight("50%");
            win.setClosable(true);
            win.setMinimizable(true);
            win.setMaximizable(true);
            String resultado = currentPersonas.GRABA_USUARIO_IMPRESION(s.getCUSUARIO_CODIGO(), s.getMenu(), currentPersonas.getDni());
                ireport.setSrc("/rpt/FOJA/FS_CABECERA.jasper");
 
    ireport.setDataConnection(s.getJdbcTemplate().getDataSource().getConnection());
    ireport.setParent(win);
 
 
 
    Map parameters = new HashMap();
 
    parameters.put("P_DNI",currentPersonas.getDni());
     parameters.put("P_RUTA","E:\\Program Files\\Apache Software Foundation\\Tomcat 7.0\\webapps\\Pentagonito\\img\\" +P_RUTA);
     parameters.put("P_RUTA_1","E:\\Program Files\\Apache Software Foundation\\Tomcat 7.0\\webapps\\Pentagonito\\img\\reportes\\001.jpg");
     parameters.put("P_RUTA_2","E:\\Program Files\\Apache Software Foundation\\Tomcat 7.0\\webapps\\Pentagonito\\img\\reportes\\002.jpg");
 
 
    ireport.setParameters(parameters);
 
    //ireport.setDatasource(dataSource);
    //ireport.setType("csv");
    ireport.setVisible(true);
    win.setParent(this);
    win.doOverlapped();
 
 
 
}catch(Exception e){
    Messagebox.show(e.toString(),this.getTitle(),Messagebox.OK,Messagebox.EXCLAMATION);
}
 
}
 
}



VERAN....!!!!
LO QUE NECESITO ES QUE CUANDO EJECUTE EL METODO IMPRIMIR...
EN ESE MOMENTO PUEDA LLAMAR A LA OTRA CLASE Y PODER UTILIZAR EL
METODO MOSTRARSELECCIONADO();


ESPERO ME PUEDAN AYUDAR, GRACIAS DE ANTEMANO.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Como llamar a una metodo desde otra clase

Publicado por Diego (28 intervenciones) el 14/01/2014 15:34:22
Hola Eduardo,

Lo que tienes que hacer, es en la clase ImprimirFojaServicios, crear un objeto de la clase CtrlReportesWnd y así heredarás todos los métodos de ésta clase.

Ejemplo
1
2
3
4
5
6
7
8
9
public class ImprimirFojaServicios{
.......
 
CtrlReportesWnd  objetoCtrlReportesWnd = new CtrlReportesWnd()
objetoCtrlReportesWnd.MostrarSeleccionado();
 
......
 
}

Un saludo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar