当前位置: 首页>>代码示例>>Java>>正文


Java Form.submit方法代码示例

本文整理汇总了Java中com.gistlabs.mechanize.document.html.form.Form.submit方法的典型用法代码示例。如果您正苦于以下问题:Java Form.submit方法的具体用法?Java Form.submit怎么用?Java Form.submit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gistlabs.mechanize.document.html.form.Form的用法示例。


在下文中一共展示了Form.submit方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectSchool

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
private HtmlDocument selectSchool(String siteURL, String schoolId) throws SchoolNotFoundException {
    MechanizeAgent agent = new MechanizeAgent();
    HtmlDocument page = agent.get(siteURL);
    Form schoolSelectionForm = page.forms().get(0);
    Select schoolDropdown = (Select) schoolSelectionForm.get("PsiId");
    List<Select.Option> schools = schoolDropdown.getOptions();
    Select.Option schoolOption = null;
    for(Select.Option school : schools) {
        if (school.getValue().equals(schoolId)) {
            schoolOption = school;
        }
    }
    if (schoolOption != null) {
        schoolOption.setSelected(true);
    }
    else {
        throw new SchoolNotFoundException();
    }
    return schoolSelectionForm.submit();
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:21,代码来源:UPassLoader.java

示例2: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
/**
 * Obtains the raw html of the data.
 * 
 * @return Evalos
 */
public Evalos login() {
    try {
        final MechanizeAgent agent = new MechanizeAgent();
        final Document page = agent.get(WEB_APP_BASE_URL);

        Form form = page.form("form1");
        form.get("username").set(username);
        form.get("password").set(password);

        HtmlDocument document = form.submit();

        parseRawHtmlResponse(document);

    } catch (Exception e) {
        connectionProblem = true;
    }

    return this;
}
 
开发者ID:robertboloc,项目名称:ho.la.urv,代码行数:25,代码来源:Evalos.java

示例3: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument nvitRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = nvitRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:NVIT.java

示例4: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.forms().get(0);    // form has no id or name

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument kuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = kuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:KwantlenUniversity.java

示例5: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("login");

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument bcitRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = bcitRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:BCIT.java

示例6: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00_ContentPlaceHolder1_UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00_ContentPlaceHolder1_PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument cuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = cuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:CapilanoUniversity.java

示例7: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("fm1");

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument ecuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = ecuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:EmilyCarrUniversity.java

示例8: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument dcRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = dcRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:DouglasCollege.java

示例9: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("aspnetForm");

    Text usernameField = (Text) authForm.get("ctl00$ContentPlaceHolder1$UsernameTextBox");
    Password passwordField = (Password) authForm.get("ctl00$ContentPlaceHolder1$PasswordTextBox");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument vccRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = vccRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());

    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:30,代码来源:VancouverCommunityCollege.java

示例10: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("loginForm");

    Text usernameField = (Text) authForm.get("userNameInput");
    Password passwordField = (Password) authForm.get("passwordInput");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument lcRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = lcRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:LangaraCollege.java

示例11: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("loginForm");

    Text usernameField = (Text) authForm.get("j_username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument ubcRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = ubcRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:UniversityOfBritishColumbia.java

示例12: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
@Override
public HtmlDocument login(HtmlDocument authPage, String username, String password, Context context) throws SchoolAuthenticationFailedException {
    Form authForm = authPage.form("fm1");

    Text usernameField = (Text) authForm.get("username");
    Password passwordField = (Password) authForm.get("password");

    usernameField.setValue(username);
    passwordField.setValue(password);
    HtmlDocument sfuRedirect = authForm.submit();

    HtmlDocument submittedPage;
    try {
        HtmlDocument translinkRedirect = sfuRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "translinkRedirect: " + translinkRedirect.getUri());
        submittedPage = translinkRedirect.forms().get(0).submit();
        LoggerUtil.appendLog(context, "submittedPage: " + submittedPage.getUri());
    }
    catch (Exception e) {
        throw new SchoolAuthenticationFailedException(e);
    }

    if (submittedPage.getUri().contains("https://upassbc.translink.ca")) {
        return submittedPage;
    } else {
        throw new SchoolAuthenticationFailedException(new Exception("Invalid submitted page URI"));
    }
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:29,代码来源:SimonFraserUniversity.java

示例13: login

import com.gistlabs.mechanize.document.html.form.Form; //导入方法依赖的package包/类
private MechanizeAgent login() throws Exception {
    AbstractHttpClient httpClient = NonverifyingSSLSocketFactory.createNonverifyingHttpClient();

    MechanizeAgent agent = new MechanizeAgent(httpClient);
    Document page = safeGet(agent, "/Login.aspx");

    Form loginForm = page.forms().get(byId("aspnetForm"));
    if (loginForm == null)
        throw new MatkakorttiException("Couldn't find aspnetForm", true);


    findField(loginForm, "UserName").set(username);
    findField(loginForm, "Password").set(password);
    FormElement loginButton = findField(loginForm, "LoginButton");
    if (!(loginButton instanceof SubmitButton))
        throw new MatkakorttiException("LoginButton is not a SubmitButton", true);

    HtmlDocument loginResponse = loginForm.submit((SubmitButton) loginButton);
    HtmlElement validationSummary = loginResponse.htmlElements().get(byId("Etuile_mainValidationSummary"));

    if (validationSummary != null) {
        HtmlElement errorList = validationSummary.get(byTag("ul"));
        if (errorList == null)
            throw new MatkakorttiException("Login response has validation summary but no error list", true);
        String errors = "";
        // - 1 since the service will always complain about our browser.
        for (int i = 0; i < errorList.getChildren().size() - 1; i++) {
            HtmlNode elem = errorList.getChildren().get(i);
            if (elem instanceof HtmlElement)
                errors += ((HtmlElement) elem).getText() + "\n";
        }
        throw new MatkakorttiException(errors, false);
    }
    return agent;
}
 
开发者ID:dezgeg,项目名称:matkakortti-widget,代码行数:36,代码来源:MatkakorttiApi.java


注:本文中的com.gistlabs.mechanize.document.html.form.Form.submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。