Bonjour,
Je souhaite utiliser un objet Java en JavaScript via DWR.
Pour simplifié, j'ai un objet java IbanRib suivant :
Et je souhaite donc appeler cet objet dans un fichier JS de cette façon:Code:
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 public class IbanRib { private String iban; public String getIban() { return iban; } public void setIban(String iban) { this.iban = iban; } public IbanRib(String iban) { if(iban != null) { this.iban = iban.trim().toUpperCase(); if(!this.isIban()){ this.iban = null; } } } private boolean isIban() { return true; } public String getBanque() { return this.iban.substring(0, 5); } }
Le problème c'est que je ne sais pas comment configurer la déclaration de mon objet. J'ai essayer ceci, mais j'ai toujours une erreur javascript :Code:
1
2
3
4
5
6
7
8
9 function methode1(){ rib = new JIbanRib($('#iban').val()); rib.getBanque(retourBanque); } function retourBanque(banque){ alert(banque); }
Merci pour votre aide :)Code:
1
2
3
4 <dwr:configuration> <dwr:create type="new" javascript="JIbanRib" class="com.leaderinfo.novanet.commons.IbanRib" /> </dwr:configuration>