이 시나리오에서 가장 좋은 해결책은 무엇일까요? Netbeans에서 구현 된 SOAP 기반 웹 서비스에서 클라이언트가 여러 체크 박스를 클릭 한 다음 서버로 전송해야합니다. 저장됩니다. 가정 내 웹 서비스 전부 또는 일부를 선택할 수 있습니다이 체크 박스가 있습니다여러 체크 박스의 값을 서버에 전달하는 방법
인종 : 1.Caucasian 2.South - 이스트 아시아 3.South 아시아 4.African 5. 기타
다른 년을 같은 웹 서비스의 일부 제가
성별과 관련된 체크 박스 구현 : 다음과 같이 1.Male 2.Female
어디 하나 또는 모두을 선택할 수 있지만 솔루션은 Ethnicity 부분에 대해 나에게 매우 복잡해 보입니다. 더 많은 체크 박스가있는 다른 부분이 있습니다!
클라이언트 측 코드 : 서버 측에 관련
private void salvaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
disease=malattia.getText();
etastr=eta.getText();
age=java.lang.Integer.parseInt(etastr);
description=descrizione.getText();
//Here i'm initiating the array using sexint as the dimension
sexarra=new String[sexint];
if(sexint==1)
sexarra[0]=sexone;
else if(sexint==0)
JOptionPane.showMessageDialog(null, "Bisogna specificare almeno un valore del campo sesso", "Errore", JOptionPane.ERROR_MESSAGE);
else{
sexarra[0]=sexone;
sexarra[1]=sextwo;}
// I define the parameters and afterwards send them to server
Vector parametri = new Vector();
parametri.addElement(new Parameter("malattia", String.class, disease, null));
parametri.addElement(new Parameter("age", int.class, age, null));
parametri.addElement(new Parameter("descrizione", String.class, description, null));
parametri.addElement(new Parameter("sexarra",String[].class, sexarra, null));
//Code related to calculating sexint which is used above as the dimension to array
private void femaleActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(female.isSelected()){
if(sexint==0){
sexint++;
sexone=female.getText();
}
else if(sexint==1){
sexint++;
sextwo=female.getText();
}
else
sexint--;
}
}
private void maleActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(male.isSelected()){
if(sexint==0){
sexint++;
sexone=male.getText();
}
else if(sexint==1){
sexint++;
sextwo=male.getText();
}
else
sexint--;
}
}
코드 :
public String aggiungi_malattia(String malattia, int eta, String descrizione, String[] sexarra) {
String ris = "no";
String q = null, w = null;
String errore = connetti();
if(sexarra.length == 2){
q = "INSERT INTO malattia (nome, eta, descrizione, sesso) "
+ "VALUES ('" + malattia + "','" + eta + "','" + descrizione + "','" + sexarra[0] + "')";
w="INSERT INTO malattia (nome, eta, descrizione, sesso) "
+ "VALUES ('" + malattia + "','" + eta + "','" + descrizione + "','" + sexarra[1] + "')";
}
{
q = "INSERT INTO malattia (nome, eta, descrizione, sesso) "
+ "VALUES ('" + malattia + "','" + eta + "','" + descrizione + "','" + sexarra[0] + "')";
당신의 시간과 노력에 대한 여러분 모두 감사합니다!
대단히 감사합니다. 저는 여전히 여러분의 solution.The 문제를 통합하기 위해 노력하고 있습니다. 그래서 Netbeans의 디자인 모드에서 인터페이스를 생성 했으므로 코드 생성기가 많이 있습니다 ... 다시 한번 감사드립니다! – rosa