java - Random Element as input and get the Value -


i don't know if it's duplicated question cause i've found nothing , didn't know keywords should i've been searching.

i want have class gets element input , shows value of element.

for example:

public void showvalue(object obj){     system.out.println("output: " + obj.getvalue()); } 

and then:

nativeselect ns=new nativeselect(); textfield tf=new textfield();  ns.addvalue("name"); ns.select("name");  tf.setvalue("lastname");  showvalue(ns); showvalue(tf); 

and have output:

output: name output: lastname 

could maybe me or give me idea how should that! i'm new java , started programming after long time.

thanks alot!

you want function can print value of every field. this:

public static void showvalue(field f) {    system.out.println("output: "f.getvalue()); //will print via console    new notification("output: "+f.getvalue()).show(page.getcurrent());     //will show text box in current page } 

as field docs (link), every field has getvalue(). should take care value types use in fields should have overriden tostring method doesn't show default tostring.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -