Special problem: Template, HTML form und dynamic page

Hello there!

I am completely new to XWiki and I am trying out some features. I am native German, so please forgive me my bad English. I hope you can help me with my “special” problem:

I would like to create a template including a HTML form which other users can use to create new pages.

Through the search function i found following instructions written in the FAQ of XWiki:
How can I create a new page based on a form?

So far so good.

The new created page (from the template & HTML form) should now be editable. For that there should be a “save changes” button at the bottom of the Page.
So that i have a “interactive page with a given, not changeable structure through HTML forms”. Users then can only edit the HTML input-areas and can’t edit the structure of the page.

Is this even possible and if yes, how?

Some additional information:

I am using XWiki 10.2 on a Ubuntu 16.04 Server (Virtual Box) witch Tomcat and MySQL.

My structur of nested pages follows this sheme:

  • Repair Manual
    ** Lenovo T570 Laptop
    *** swap HDD
    *** swap RAM
    *** add RAM
    ** Lenovo X380 Yoga
    *** etc.

For example, the new created/editable nested page should be created at “swap HDD”.

My code-base so far. (DON’T WORK!)

{{velocity}}
#if("$!request.docName" != '')
## Request for creating a new instance
#set($targetDocReference = $services.model.createDocumentReference('', $!{request.spaceName}, $!{request.docName}))
$response.sendRedirect($xwiki.getURL($targetDocReference, 'inline', "template=${escapetool.url($request.template)}&parent=${escapetool.url($request.parent)}"))
## Stop processing, since we already sent a redirect.
#stop
#end


{{html}}
<input type="hidden" name="parent" value="${doc.fullName}"/>
<input type="hidden" name="template" value="XWiki.Tmpl_form_AA_03"/>
<input type="hidden" name="sheet" value="1"/>
<input type="hidden" name="spaceName" value="Repair Manual"/>

<form action="" id="newdoc" method="post">

working-step name: <input type="text" name="docName" value="for example: swap HDD" class="withTip" size="50"/>
    <p></p>

    <table>
        <tr>
            <th align="left">
                Bild:
            </th>
            <th align="left">
                short-description:
            </th>
        </tr>
        <tr>
            <td>
                IMAGE HERE
            </td>
            <td>
                <textarea name="short-description" id="short-description" cols="80" maxlength="500"></textarea>
            </td>
        </tr>
    </table>

    <table>
        <tr>
            <th>
                &nbsp;
            </th>
            <th align="left">
                steps:
            </th>
            <th align="left">
                needed tools:
            </th>
            <th align="left">
                needed parts:
            </th>
        </tr>
        <tr>
            <td>
                01:
            </td>
            <td>
                <textarea name="step01" id="step01" maxlength="200"></textarea>
            </td>
            <td>
                <textarea name="tool01" id="tool01"></textarea>
            </td>
            <td>
                <textarea name="part01" id="part01"></textarea>
            </td>
        </tr>
        <tr>
            <td>
                02:
            </td>
            <td>
                <textarea name="step02" id="step012" maxlength="200"></textarea>
            </td>
            <td>
                <textarea name="tool02" id="tool02"></textarea>
            </td>
            <td>
                <textarea name="part02" id="part012"></textarea>
            </td>
        </tr>
    </table>


    <span class="buttonwrapper"><button type="button" id="add new step">neuen Schritt hinzufügen</button></span>
    &nbsp;
    <span class="buttonwrapper"><button type="button" id="delete last step">letzten Schritt löschen</button></span>
    <p></p>

    <span class="buttonwrapper"><input type="submit" value="save" class="button"/></span>

</form>

{{/html}}
{{/velocity}}

Hi, you should really look into using XClass and XObjects. See http://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/FAQTutorial/FAQTutorialManual (you should follow this tutorial to understand how this works).

Hope it helps

Wow, that was really helpful! Thanks very much.

I think i understood how i can use classes to create the editable template which i want to have.

I also tested it a little bit and it worked great!

One Question popped up while testing:
Is there a way to add a new property of the type “picture” to my class?
When creating a new page through my new template, i would like to give the user a possability to upload a picture. Unfortanately there is no typ “picture” in the selection possibility.

And another question:
Can you give a recommendation for a good book to learn more about velocity?

Not easy but doable. See http://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/CreatingNewXClassPropertyTypes/

Velocity is really simple, what you need to learn is the XWiki Java API that exist and that you can call from Velocity.

See:

Side note: please mark the answer as “solved” when some answer solves your question. Thx!