genexus sdk introductory workshopsvn2.assembla.com/svn/gxextensions/trunk/sdkworkshop/... · web...

15
How to Debug a Extension / Pattern http://wiki.genexus.com/commwiki/servlet/hwikibypageid?12138 Make sure to compile your project using the Debug option from the Solution Configurations list box. When generating a new pattern make sure to enable the Debugging options for Patterns. Set the project as the Startup one in Visual Studio and configure the GeneXus.exe complete path in the Project -> Properties -> Debug -> Start action -> Start external program. My First Pattern http://wiki.genexus.com/commwiki/servlet/hwikibypageid?9947 The Pattern will generate a SDT object representing the structure of a given transaction. For instance, given the Country transaction:

Upload: others

Post on 31-Dec-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

How to Debug a Extension / Pattern

http://wiki.genexus.com/commwiki/servlet/hwikibypageid?12138

Make sure to compile your project using the Debug option from the Solution Configurations list box.

When generating a new pattern make sure to enable the Debugging options for Patterns.

Set the project as the Startup one in Visual Studio and configure the GeneXus.exe complete path in the Project -> Properties -> Debug -> Start action -> Start external program.

My First Pattern

http://wiki.genexus.com/commwiki/servlet/hwikibypageid?9947

The Pattern will generate a SDT object representing the structure of a given transaction.

For instance, given the Country transaction:

the following SDT will be generated:

Page 2: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

The steps are:

1. Read Creating a New Pattern in order to understand all relationated concepts about GeneXus Patterns and the necessary requirements to develop a Pattern.

Note: If you want to continue developing the Pattern without reading the documentation on step 1, you should install GeneXus X, GeneXus X/GeneXus Platform SDK and Visual Studio 2005 or higher

2. Create a New Visual Studio Project: File->New->Project

3. Select GeneXus Pattern Template:

Page 3: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

4. Enter data according to your preferences, press Next

Page 4: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

5. Select Transaction as object for the pattern to be applied:

Page 5: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

6. Enter type and name for the object to be generated, press Next

Page 6: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

7. Indicate that GeneXus will be launched after making Start of your project. In order to do this in Visual Studio go to: Project->MyFirstPattern Properties->Debug and indicate the path to GeneXus.exe on Start external program

Page 7: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

8: Copy the following code into the template to create the SDT structure (SDTSDTStructure.dkt) below this code: <Part type="<%= PartType.SDTStructure %>">:

<%-- Sample SDT Structure definition--%>

<%-- Indicate that the generated SDT object will be Collection, this will take place adding a property with Name = AttCollection and Value = True --%>

<Level Name="<%= Object.Name %>"> <LevelInfo guid="<%= Guid.NewGuid() %>"> <Properties> <Property> <Name>AttCollection</Name> <Value>True</Value> </Property> </Properties> </LevelInfo>

<%-- Process the list of attributes of the transaction where the pattern is being applied --%><% foreach (TransactionAttribute trnAtt in myInstance.ParentObject.Structure.Root.Attributes) {%>

<%-- Create a field into the "SDT" using the same Name and Description of the transaction attribute (trnAtt), --%><%-- and the field type will be based on the attribute type --%> <Item guid="<%= Guid.NewGuid() %>" name="<%=trnAtt.Name%>" description="<%=trnAtt.Attribute.Description%>"> <Properties> <Property> <Name>idBasedOn</Name> <Value>Attribute:<%=trnAtt.Name %></Value> </Property> </Properties> </Item>

<%-- Process the levels of the transaction --%> <% } foreach (TransactionLevel level in myInstance.ParentObject.Structure.Root.Levels) {%>

<%-- For each level of the transaction, a level into SDT object will be created and the same name and description will be assigned. In addition it will be marked as Collection --%> <Level Name="<%=level.Name%>"> <LevelInfo guid="<%= Guid.NewGuid() %>">

Page 8: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

<Properties> <Property> <Name>Name</Name> <Value><%=level.Name%></Value> </Property> <Property> <Name>AttCollection</Name> <Value>True</Value> </Property> </Properties> </LevelInfo>

<%-- Process the attributes of each level and create a field with type based on the attribute level type --%><% foreach (TransactionAttribute trnAtt in level.Attributes) {%>

<Item guid="<%= Guid.NewGuid() %>" name="<%=trnAtt.Name%>" description="<%=trnAtt.Attribute.Description%>"> <Properties> <Property> <Name>idBasedOn</Name> <Value>Attribute:<%=trnAtt.Name %></Value> </Property> </Properties> </Item>

<% } %> </Level><% } %> </Level></Part>

9. Do Rebuild All

10. Press F5

11. Apply the pattern!!

Page 9: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

PatternBuilder

http://wiki.genexus.com/commwiki/servlet/hwikibypageid?9816

The Pattern Builder is a tool that is installed with the GeneXus X/GeneXus Platform SDK (available from GeneXus X Platform SDK Upgrade #3) and is executed within Visual Studio 2005|2008.

The wizard provided in the pattern builder allows creating, in just a few steps, new patterns for GeneXus X .

The wizard prompts you for this information:

Objects to which the pattern will be applied Objects to be generated

Then, it generates a Visual Studio project for creating the pattern, with all the xml files and the configured environment.

Next, with the Template Editor and CodeGen included in the GeneXus X SDK, you can continue to develop the pattern.

The Template Editor can be used to edit the templates from within Visual Studio and CodeGen facilitates the generation of the classes to manipulate the instances. It generates generic xml files so that the developer can continue to develop these files.

Page 10: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

Select New Project, and in the project window choose GeneXus Pattern.

Write the name and route where the Pattern will be generated:

Step 1

Indicate the Company name.

Page 11: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

Step 2

Indicate which objects the patterns will be applied to (parent objects).

Page 12: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

Step 3

Select which objects will be generated by the pattern and their names.

Page 13: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

Once you complete the Wizard, the Pattern Builder generates a Visual Studio project with all the files and configurations necessary to continue to develop the pattern.

The Pattern Builder generates a template file for each part of the object to be generated. .

In the example, we indicated that the pattern will generate a procedure. Therefore, the following templates were generated:

ExportConditions.dkt ExportLayout.dkt ExportProcedure.dkt ExportRules.dkt ExportVariables.dkt

Each one of them represents one part of the object, and in each one of them we should include the necessary code to generate what we want in that part.

The Template Editor makes editing the templates easier by allowing you to manipulate the files more easily.

Page 14: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

In the Visual Studio project, they are the files located under the Template folder:

After you finish developing the templates, select the project's Build option:

Page 15: GeneXus SDK Introductory Workshopsvn2.assembla.com/svn/gxextensions/trunk/SDKWorkshop/... · Web viewThen, it generates a Visual Studio project for creating the pattern, with all

When Building the project, the CodeGen is executed, which is a utility that allows generating extensible classes for accessing the instances. This can viewed in the Visual Studio output.

Next, all the necessary files are copied under the GeneXus directory. Thus, upon executing GeneXus the new pattern will be displayed that is associated with the object set as parent object, and in Preferences / Pattern there will be a file corresponding to the default instance of the new Pattern.