Download Language Workbench Challenge 2013 Xtext Submission

Transcript
LWC13 if (input.URI.fileExtension!="ql")
6
7
return
8
// model root
val questionnaire = input.contents.head as Questionnaire
9
// generate index page with links to generated forms
10
11
val contentIndex = generate_FormIndex(questionnaire.forms)
12
val fileNameIndex = "generated/forms/index.xhtml"
13
fsa.generateFile(fileNameIndex,WEB_CONTENT, contentIndex)
14
...
15
16
17
Submission
}
...
}
For the new artifact add a new extension called def generate_FormIndex. It receives a list of
Form elements. In a short loop it generates a html:outputlink node for each element in the
given list of forms. Because doGenerate is called for each QL resource, the generator currently
has the limitation that all QL model elements have to be defined within the same QL resource
to ensure generation of a correct form index page.
1
def generate_FormIndex (List<Form> forms)
2
’’’...
<ui:composition template="/index.xhtml">
3
<ui:define name="content">
4
5
«FOR elem: forms SEPARATOR "<br/>"»
6
<h:outputLink value="«elem.name».jsf">«elem.name»</h:outputLink>
7
«ENDFOR»
8
9
</ui:define>
10
11
</ui:composition>
12
...
13
’’’
By using the attribute template of a composition tag as already described in 3.1.3, the
structure and styles of index.xhtml will be derived in our form index page. Our generated
form index needs a index.xhtml in the applications root folder which itself or one of its parent
templates defines a facelet:insert section with name ’content’ like described in section 3.1.3.
To get the possibility to change the template for all generated files in a single file easily later
we will use the generated form index as template for generated form pages in a later step. The
generated form index looks similar to the one described in section 3.1.4.
53