8

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?

Hedge
  • 16,142
  • 42
  • 141
  • 246

2 Answers2

18

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)

Paul Schyska
  • 666
  • 8
  • 17
1

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
jbbarquero
  • 2,842
  • 2
  • 19
  • 17