How can I customize the template of my field plugin? how to apply bootstrap classes to it?
Where can I get the default template of a f:field (for example) to customize it ?
Thank you
You can check documentation of grails field plugin, I think is very clear Grails Field Plugin Custimization Page
In resume, you have to create gsp file templates, for the diferent fields, it can be done by varios options for example property type, propery name, controller, action, etc. In those template files you can apply the bootstrap clases you want to use.
Related
For passing XSRF token with Struts2 forms, I have to put the token tag inside all forms. The baseline jsp in tiles-def can't have an all-encompassing form.
Have you ever extended the form tag to include token tag by default or know of some library that does that?
I haven't explored Freemarker template, so do not know if this is feasible or not. If there are no existing solution, I'll try to build my own.
To consolidate from the comments section,
1) Create a new theme
2) Extend "form-close.ftl" to this
<#s.token/>
<#include "/${parameters.templateDir}/xhtml/form-close.ftl" />
Add tokenSession (or token) interceptor in your stack.
With these changes, all struts forms will have a struts-token added without specifying <s:token> in each of them.
I want to extend Struts 2 s:select tag.
Can somebody explain step required to do the same.
Also if there is any hook or implementation available in Struts2 framework for the same
I think you can change the freemarker template as you need and extend org.apache.struts2.views.jsp.ui.SelectTag class.
Check this article to start with.
You can start by examining the freemarker templates (default is freemarker but it can be velocity or some other template engine). See http://mikeski.net/site/node/16.
If that is not enough for you then you could extend or create your own implementation of select tag. http://joshuajava.wordpress.com/2008/12/27/creating-custom-components-with-struts-2/
I know that there are already richtext plugins for grails like RichUI, CKEditor, FckEditor etc, but is there any plugin which binds itself with grails so well that when I can use a rich textbox just by specifying widget attribute under the constraints clause
Example
static constraints = {
dateCreated display:false
lastUpdated display:false
question nullable:true, widget:"richtext"
}
I don't know of such a feature, but I guess you can solve this by yourself:
use install-templates to get the scaffolding (and generate-all) templates http://grails.org/doc/latest/ref/Command%20Line/install-templates.html
you'll find a file called renderEditor.template and in this a method called renderStringEditor
there you'll find how to render the input tag based on the value of the widget constraint
Would be a nice addition to the existing plugins.
btw: FckEditor seems to be a little bit old and I guess CKEditor should be used instead.
I have a form with two selects, but the second select is optional depending on the value selected from the first. For instance:
<select name="country" from="['US', 'CA']">
<select name="language" from="['FR', 'EN']" disabled=true>
Only if CA was selected from country do I want language combobox active.
Grails doesn't provide a way to do this by default. Since GSP tags allow you to use normal HTML events you would need to write JavaScript to enable and disable the second select based on the value of the first. You will want to look at the onchange event to do this. If you need to do a lot of custom UI type stuff you may want to look at using a JavaScript plugin for Grails. Prototype is included with Grails by default. Several other java script libraries are available as Grails plugins including jQuery and YUI
I agree, javascript is what you want. I'd recommend writing this in JQuery, since Grails is going to making that the default (over Prototype) in, I believe, v1.4. To do this in JQuery it would be something like this:
$("[name=country").change(function() {
$("[name=language]").attr("disabled", ($(this).val() == "CA"));
});
I am using SF 1.2.9 (with Propel ORM), to build a website. I have generated admin modules for some of my models. I want to modify the template used to display the Form because there are some fields that I dont want to display (but need) - example the 'slug' field in a form.
Since the templates are autogenerated, I cant make the changes there. How can I specify a template to use for rendering a form in the new/edit view?
In general, to override generated templates with your own, you just have to name your template same as generated one.
But looks like you do not need it. Hint: you can choose which fields to show in admin generator. Please consult symfony reference manual to realize how
To hide or remove fields from a form, I think you should check that link.
To sum up, the admin generator uses a ORM sfForm to render the edit action. So if you remove fields:
// lib/form/doctrine/ADoctrineClassForm.class.php
class ADoctrineClass extends BaseADoctrineClass
{
public function configure()
{
...
unset($this['field_name']
...
You can also change the widget used the render the field by redefining which widget to use:
//in ADoctrineClass configure method also
$this->widgetSchema['a_field_a_want_to_hide'] = new sfWidgetFormInputHidden()
I hope this helps.