开发者

How to create custom View and Layouts in Grails

I am wanting to create a page that can load a property file into a text box, edit the properties, and then save the new properties to the file.

Would this be possible by simply using HTML markup? How do I get the push buttons to correlate with my Grails application?

The HTML seems simple enough:

<p>
Select property file:
<input type="file" name"propertyList" size="50"/>
</p>

<p>
<input type="submit" value="Open File"/>
<input type="submit" value="Save File"/>
</p>

<p>
<input type="text" name="properties" size="300"/>
</p>

I'm not quite sure about the submit button as I don't know a whole lot of HTML.

My goal is to simply locate the property file, use groovy to open it and read it line by line and display it in the text box, then be able to edit the properties and save it.

My biggest question deals with the buttons. How do I have the Open File use the button event (onclick) to activate a function 开发者_JAVA百科I have written in groovy? Or instead of a submit button, what type of input should I use?

Any information leading me in the right direction would be appreciated

EDIT

Is it correct to do something like the following:

<input type="button" onclick="<g:link action="readFile" controller="propertyRead">Open File</g:link>"/>

If not, what would be the proper way to go about it?

EDIT 2

I looked into actionSubmit and also looked a bit more into g:link and was wondering which way (if either) is the better way to go:

actionSubmit (unsure if it allows one to specify the controller as it wasn't stated in the attributes):

<g:actionSubmit value="Open File" action="readFile" controller="propertyRead"</g:actionSubmit>

Or using a menuButton and g:link

g:link:

<span class="menuButton"><g:link action="readFile" controller="propertyRead">Open File</g:link>

Also forgot to ask, is there a way to get the file path from the input type="file" ?


In order to make full use of Grails functionality, you'll probably want to use the associated HTML tags - form (or uploadForm for a form that's uploading the file) and actionSubmit. Grails doesn't offer a custom file input for reasons which I don't remember, so you'll need to use the <input type="file" ...> as shown in your example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜