English 中文(简体)
Vaadinlogin 形式布局——超文本
原标题:Vaadin LoginForm layout - HTML

I m facing problem trying to set horizontal layout to LoginForm of Vaadin. The only solution for which I have an idea is overriding getLoginHTML() class so that it return the proper code. I ve added style="float:left" which worked for me in normal html.

部分法典的修改反映了这一点:

(...) + "<div class= v-app v-app-loginpage  style="background:transparent;">"
        + "<iframe name= logintarget  style= width:0;height:0;"
        + "border:0;margin:0;padding:0 ></iframe>"
        + "<form id= loginf  target= logintarget  onkeypress="submitOnEnter(event)" method="post">"
        + "<div style="float: left;">"
        + getUsernameCaption()
        + "</div><div style="float: left;">"
        + "<input class= v-textfield  style="float: left;" type= text  name= username ></div>"
        + "<div style="float: left;">"
        + getPasswordCaption()
        + "</div>"
        + "<div style="float: left;"><input class= v-textfield  style= display:inline; float:left;  type= password  name= password ></div>"
        + (...)

这种做法是顺便说一句的:用户的田地和口号是相同的,而其他所有的人都是不同的。 因此,它希望:

用户名

用户外勤密码

密码:

Button

And as I said I would like it to be algined horizontally... any ideas?

问题回答

这是你为什么要使用LoginForm的原因。 既然答案不定,你可以采用瓦亚丁简单表格,使你的形式更加灵活。 例如

public class FormBean{
private String username, password;

//getters and setters
}


    HorizontalLayout newLayout = new HorizontalLayout();

    Form form = new Form(newLayout){
        @Override
        protected void attachField(Object propertyId, Field field) {
            String fieldName = (String) propertyId;

            if(fieldName.equals("username")){
                Label usernameLabel = new Label("username: ");
                newLayout.addComponent(usernameLabel);
                newLayout.addComponent(field);
            }
        }
    };
    form.setItemDataSource(new FormBean());
    form.setFormFieldFactory(new FormFieldFactory() {

        @Override
        public Field createField(Item item, Object propertyId, Component uiContext) {
            String fieldName = (String) propertyId;
            if(fieldName.equals("username")){
                TextField field = new TextField();
                field.setImmediate(true);
                //Here your can add some validations on "fly", for example is username allow only latin characters
                field.addListener(new TextChangeListener() {

                    @Override
                    public void textChange(TextChangeEvent event) {
                        String currentText = event.getText();
                        //Here go validation
                    }
                });
            }
            return null;
        }
    });

如实地需要,可按实地格式确定,建立一些验证人等。 如果你想确定某种验证,我建议使用Vadin Add-on BeanValidationForm,允许在POJO的物体内使用说明,以形成一些规则,例如@NotNull,@Max,@Min等。

@NotNull(message = "Username required")
private String username = "";

@NotNull(message = "Password required")
private String userpass = "";




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签