Login Dialog - Keyboard Handling

Hi there,

since I have not found a solution for our little
problem in the forum yet,
I would like to share it with you:

We have implemented a little Dialog to log in.
It has two fields and a submit button. An Adapter is bound to that Dialog.
Our problem is, that the user has to press the submit button every time,
because the keyboard stroke ENTER does not consider the text inside the password field.

Desired Usage:
The User inputs username, then presses tab and then enters the password and then presses ENTER on his keybord.
In our implementation when hitting ENTER the method “getUserPwd” inside the adapter class returns null…

Has anybody a solution for this?

Thanks in advance.

Why don’t you try to validate your fields against your business rules before processing them ? Also by usign "statusprop " property of field you can give warning messages & focus on any field.

The login works fine, when hitting the SUBMIT button.
The moment I am still inside the Password field with cursor,
and hit keyboard’s ENTER key the variable bound to that field is empty.

I tried also the flush with server and screen, but did not work properly.

It seems normal to me.If you don’t want to get null value you should initialize your members. I’m sending sample code , I hope it helps you .


package test;

import com.softwareag.cis.server.Adapter;
import com.softwareag.cis.util.IControlStatusConstants;

public class LoginAdapter extends Adapter {

	private String user;
	private String password;
    private String fieldStatusUser;
    private String fieldStatusPassword;
    
    
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getUser() {
		return user;
	}
	public void setUser(String user) {
		this.user = user;
	}

    public String getFieldStatusUser()
    {
        return fieldStatusUser;
    }

    public String getFieldStatusPassword()
    {
        return fieldStatusPassword;
    }
    
    
    
	public void setFieldStatusPassword(String fieldStatusPassword) {
		this.fieldStatusPassword = fieldStatusPassword;
	}
	public void setFieldStatusUser(String fieldStatusUser) {
		this.fieldStatusUser = fieldStatusUser;
	}
	
	@Override
	public void init() {
		super.init();
		user="";
		password="";
	}
	
	@Override
	public void reactOnDataTransferStart() {
		super.reactOnDataTransferStart();
		setFieldStatusPassword(IControlStatusConstants.CS_EDIT);
		setFieldStatusUser(IControlStatusConstants.CS_EDIT);
	}
	
	public void onEnter(){
		if (! isValid()) return;
		logonProcess();
	}
	
	public void onOkButtonPressed(){
		if (! isValid()) return;
		logonProcess();
	}
	
	private void logonProcess(){
		//TODO implement your logon process here
	}
	
	private boolean isValid(){
		if (user == null || user.trim().length() == 0){
			setFieldStatusUser(IControlStatusConstants.CS_ERROR);
			outputMessage("E","User name required");
            return  false;
		}
		if (password == null || password.trim().length() == 0){
			setFieldStatusPassword(IControlStatusConstants.CS_ERROR);
			outputMessage("E","Password required");
			return false;
		}
		return true;
	}
}

Page Code


<?xml version="1.0" encoding="UTF-8"?>
<page model="test.LoginAdapter" translationreference="logonPage" popupwidth="400px" popupheight="250px" immediatedisplay="true">
    <titlebar textid="logonTitle" withclose="false">
    </titlebar>
    <header withdistance="false">
    </header>
    <pagebody>
        <rowtable0>
            <vdist height="10">
            </vdist>
            <tr>
                <label textid="user" width="100">
                </label>
                <field valueprop="user" statusprop="fieldStatusUser" length="32" tabindex="0">
                </field>
            </tr>
            <tr>
                <label textid="password" width="100">
                </label>
                <field valueprop="password" flush="screen" statusprop="fieldStatusPassword" length="32" password="true" tabindex="1">
                </field>
            </tr>
            <vdist>
            </vdist>
            <tr>
                <hdist>
                </hdist>
                <coltable0 width="100" takefullheight="true">
                    <itr>
                        <button textid="logon" method="onOkButtonPressed" tabindex="3">
                        </button>
                    </itr>
                </coltable0>
            </tr>
            <vdist height="50">
            </vdist>
        </rowtable0>
    </pagebody>
    <statusbar typeprop="messageType" shorttextprop="messageShortText" longtextprop="messageLongText" withdistance="false">
    </statusbar>
    <hotkeys>
        <hotkey keycode="13" method="onEnter">
        </hotkey>
    </hotkeys>
</page>

Wow thanks!
I think I got it.