Carriage return in every textfields

2013-02-19
2013-03-06
  • Erieze Lagera

    Erieze Lagera - 2013-02-19

    Hello,

    I'm developing a program that will be used to work with a Barcode Scanner. By default, the device was adding a carriage return at the end of scanned code. I was thinking to add an "Enter" keystroke in my controller but no luck.

    How will I execute the controller by simply pressing enter key in a textfield?

    Thank you!

     
  • Javier Paniza

    Javier Paniza - 2013-02-21

    Hi Erieze,

    How will I execute the controller by simply pressing enter key in a textfield?

    You have to define your action as the default one, in this way:

    <action name="myActionOnReturn" 
        class="com.mycompany.myapp.actions.MyActionOnReturnAction" 
        by-default="always"/>
    

    Hava a look at the doc of action in wiki.


    Help others in this forum as I help you.
    Before posting a question search this forum for the answer,
    and read the OpenXava documentation in openxava.org.

     
  • Erieze Lagera

    Erieze Lagera - 2013-02-21

    Hello!

    I already added "by-default" action to my controller but still not working with ENTER key.

    My view contains only 1 writable text field and the rest are read only text fields.

    I tried other view and it only works at List view (filtering).

     
  • Javier Paniza

    Javier Paniza - 2013-02-25

    Hi Erieze,

    My view contains only 1 writable text field and the rest are read only text fields

    So, if you put the focus and the writable field and press enter the default action is not executed?

    Create a miniproject with only an simple entity, a custom action and a controller. Then try to reproduce your case on it. If it fail put here the source code for the entity, action and controller. I will give some advice.


    Help others in this forum as I help you.
    Before posting a question search this forum for the answer,
    and read the OpenXava documentation in openxava.org.

     
  • Erieze Lagera

    Erieze Lagera - 2013-02-25

    Hello Javier,

    The action just works, but only with fields from Entity class. That's it, "by-default" actions only works with fields generated from Entity class. My problem is that I'm working with text field from a Transient class.

    This is my Transient class code looks like,

    public class EmployeeTimeRecord {

    private int number;

    @OneToOne( fetch = FetchType.LAZY )
    @ReadOnly
    private Employee employee;

    public int getNumber() {
    return number;
    }

    public void setNumber(int number) {
    this.number = number;
    }

    public Employee getEmployee() {
    return employee;
    }

    public void setEmployee(Employee employee) {
    this.employee = employee;
    }

    }

     
  • Javier Paniza

    Javier Paniza - 2013-02-27

    Hi Erieze,

    I tried your code and you're right, the action is not executed on RETURN. The problem is not because the class is transient but because the property is int.
    It's an OpenXava bug, the return is not recognized for int textfields. Please, add the bug and we'll fix it in future OX releases.

    In the meantime use String for your number property.


    Help others in this forum as I help you.
    Before posting a question search this forum for the answer,
    and read the OpenXava documentation in openxava.org.

     
  • Erieze Lagera

    Erieze Lagera - 2013-03-04

    Hello Javier,

    It is now working with Data type of String. Thank you very much!
    And also I forwarded the bug to "bugs section".

    Again, Thank you very much!

     
  • Javier Paniza

    Javier Paniza - 2013-03-06

    Hi Erieze,

    Thank you very much!

    The best way to give me thanks is helping others in this forum.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks