我是新角色如何使用自定义验证来验证多个checkbox
的数组,我希望在button
选中checkbox
之前禁用import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import static java.net.URLEncoder.encode;
public class Main {
public static void main(String[] args) throws IOException {
PrintWriter pw = new PrintWriter(new File("Participants.csv"), "windows-1251");
final String colNames = "Name;Country;Address;Phone;Fax;Site;Descr";
StringBuilder builder = new StringBuilder();
builder.append(colNames + "\n");
final String url = "http://www.world-food.ru/ru-RU/about/exhibitor-list.aspx";
String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36";
Connection.Response response = Jsoup.connect(url).execute();
Document document = response.parse();
String viewState = encode(document.getElementById("__VIEWSTATE").attr("value"), "UTF-8");
String eventTarget = encode("p$lt$ctl12$pageplaceholder$p$lt$ctl01$UniPager$pagerElem" , "UTF-8");
for (int i = 1; i <=71 ; i++) {
document = Jsoup.connect(url).userAgent(userAgent)
.requestBody(
String.format(
"__EVENTTARGET=%s" + "&__EVENTARGUMENT=%d" + "&__VIEWSTATE=%s",
eventTarget, i , viewState ))
.cookies(response.cookies())
.post();
Elements subList = document.getElementsByClass("name showframe");
for (int j = 0; j < subList.size(); j++) {
Document compPage = Jsoup.connect(subList.get(j).absUrl("href")).post();
Elements compPageData = compPage.getElementsByClass("name");
builder.append(subList.get(j).html().replace(';',',') + ";");
// System.out.println(subList.get(j).html().replace(';',',') + ";");
builder.append(subList.get(j).siblingElements().first().text()+ ";");
// System.out.println(subList.get(j).siblingElements().first().text()+ ";");
for (int k = 0; k <compPageData.size() ; k++) {
builder.append(compPageData.get(k).siblingElements().text().replace(';', ',') + ";");
// System.out.print(compPageData.get(k).siblingElements().text().replace(';', ',') + ";");
}
builder.append('\n');
}
}
pw.write(builder.toString());
pw.close();
}
}
。
答案 0 :(得分:1)
您必须订阅您的复选框控件并在其值更改时对其作出反应(启用/禁用按钮)。类似的东西:
this.myForm.controls.isEnableCheckbox.valueChanges
.subscribe(checked => {
if(checked){ // here you enable or disable the button or you can set a variable to do that...
this.myForm.controls.buttonToEnable.enable();
} else {
this.myForm.controls.buttonToEnable.disable();
}
});