Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add fields to entities in the roo-shell?

I'd like to add fields to an already created entity in the roo-shell but I don't know which command puts an entity in the current context.

Which one does that?

like image 360
Hedge Avatar asked Jul 27 '11 11:07

Hedge


2 Answers

You have to "focus" that class first to add or change fields on it

roo> focus --class ~.LaserCannon
~.LaserCannon roo> field number --fieldName strength --type double
Updated SRC_MAIN_JAVA/com/stackoverflow/LaserCannon.java
Updated SRC_MAIN_JAVA/com/stackoverflow/LaserCannon_Roo_JavaBean.aj
Updated SRC_MAIN_JAVA/com/stackoverflow/LaserCannon_Roo_ToString.aj

Which added field "strength" to my class com.stackoverflow.LaserCannon (~ is evaluated by roo to your project's top-level-package)

like image 96
Paul Schyska Avatar answered Nov 02 '22 17:11

Paul Schyska


You can use the "--class" attribute in the "field" command as well.

In the roo console use the tab key for suggestion with the commands (or ctrl+space in the STS [even in Mac])

See Field Commands reference

For instance:

roo> field string --fieldName borrar --class ~.domain.Comercio
Updated SRC_MAIN_JAVA\com\malsolo\stackoverflow\domain\Comercio.java
Updated SRC_MAIN_WEBAPP\WEB-INF\i18n\application.properties
Updated SRC_MAIN_JAVA\com\malsolo\stackoverflow\domain\Comercio_Roo_JavaBean.aj
Updated SRC_MAIN_JAVA\com\malsolo\stackoverflow\domain\Comercio_Roo_ToString.aj
Updated SRC_TEST_JAVA\com\malsolo\stackoverflow\domain\ComercioDataOnDemand_Roo_DataOnDemand.aj
Updated SRC_MAIN_WEBAPP\WEB-INF\views\stack\comercios\list.jspx
Updated SRC_MAIN_WEBAPP\WEB-INF\views\stack\comercios\show.jspx
Updated SRC_MAIN_WEBAPP\WEB-INF\views\stack\comercios\create.jspx
Updated SRC_MAIN_WEBAPP\WEB-INF\views\stack\comercios\update.jspx
like image 35
jbbarquero Avatar answered Nov 02 '22 17:11

jbbarquero