Domanda

Being reserved in JVM as a keyword, new should be escaped with 2 single back quote signs to be used in Play as a name of an action (new, create, edit, update, index, delete, show). I think it causes inconvenience.

Is there another de-facto action name in Play to replace new?

È stato utile?

Soluzione

In Play you can use any (not reserved in language) name for action, so it can be for an example newItem. It will be clear if in one controller you'll want to add actions for all models ie: newPost, editPost, newComment, editComment, etc.

If you'll use separate controllers for each model (which is better) you can also add an Action suffix to your actions newAction, editAction etc. Although seems redundant finally it's easier to use it later with implicit imports to differ ie. indexAction from indexView.

P.S. My favorite name for this action is add - but as you can see it's rather matter of taste not pattern.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top