I'm guessing it is because you are missing the name attributes on you're
inputs. You might want to try the following form:
<form action="/cluster-add.xqy" method="get" class="form-horizontal">
<fieldset style="border: 0px;">
<legend>Add cluster</legend>
<div class="control-group">
<label class="control-label" for="name">Name</label>
<div class="controls">
<input class="input-xlarge" id="name" name="name" type="text"/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="id">Identifier</label>
<div class="controls">
<input class="input-xlarge" id="id" name="id"
style="font-family:monospace;" type="text"/>
</div>
</div>
<input type="hidden" id="aqt" name="apt" value="1"/>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Create</button>
<button type="reset" class="btn">Reset</button>
</div>
</fieldset>
</form>
Also, a best practice in web development is to not make updates on a GET
request. It is best to use POST for creating, PUT for updating, and DELETE
for deleting (Although I believe you have to make use of the
javascript XMLHttpRequest
or some other method for PUT and DELETE since most, if not all, browsers
don't currently support PUT and DELETE at the moment.) You can use
xdmp:get-request-method() to check which method the request is using.
-Ryan Dew
On Tue, May 29, 2012 at 5:56 AM, Jashank Jeremy <[email protected]>wrote:
> G'day,
>
> I'm still relatively new working with XQuery, so if I've done something
> blatantly and obviously wrong, please don't hurt me!
>
> I'm building a webapp in pure XQuery, and using it to teach myself the
> basics of XQuery.
>
> I have a '/cluster-add.xqy', which looks at the value of a hidden value
> (I need a better way to do it, but that's not critical) and switches
> between a form and an xdmp:document-insert(). If the form has
> method="get", nothing happens when I submit -- I just wind up back at an
> unpopulated '/cluster-add.xqy'. If I go to
> '/cluster-add.xqy?aqt=1&name=Test&id=test', then the document-insert()
> runs.
>
> My program, when stripped down to the bare essentials, looks like this.
>
> return
> if (xdmp:get-request-field('aqt'))
> then
> (: inject content into the database :)
> else
> (: generate form :)
>
> The form itself looks like this. I use Twitter Bootstrap to do styling.
>
> <form action="/cluster-add.xqy" method="get" class="form-horizontal">
> <fieldset style="border: 0px;">
> <legend>Add cluster</legend>
> <div class="control-group">
> <label class="control-label" for="name">Name</label>
> <div class="controls">
> <input class="input-xlarge" id="name" type="text"/>
> </div>
> </div>
> <div class="control-group">
> <label class="control-label" for="id">Identifier</label>
> <div class="controls">
> <input class="input-xlarge" id="id"
> style="font-family:monospace;" type="text"/>
> </div>
> </div>
> <input type="hidden" id="aqt" value="1"/>
> <div class="form-actions">
> <button type="submit" class="btn btn-primary">Create</button>
> <button type="reset" class="btn">Reset</button>
> </div>
> </fieldset>
> </form>
>
> Any thoughts?
>
> Thanks in advance,
>
> Jashank
>
> --
> Jashank Jeremy
> PGP: 0x25A5C309
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://community.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
http://community.marklogic.com/mailman/listinfo/general