Difference between pages "Developing codeunits" and "FieldCodeunitPage"

From TempusServa wiki
(Difference between pages)
Jump to navigation Jump to search
old>Admin
 
m (3 revisions imported)
 
Line 1: Line 1:
== Steps for creating a new codeunit ==
= Button: Codeunit execution =
Execute proprietary code


# Create a new Java project in your favorite IDE
Properties
# Import the p2eShared.jar in the project
* Type: [[Field type reference#Action button|Action button]]
# Create a new class:
* Groupable: No
## The abstract parts are found in: dk.p2e.blanket.codeunit
* Show in lists: No
## Implement all abstract methods
* Searchable: No
## Code the method bodies (normally "execute")
# Compile and build
# Deploy to webservser: [Application]\WEB-INF\lib


After first test of the codeunit a server reboot is needed for each redeployment, as there is no way of removing the loaded classes from memory.


== Error handling ==
== User interface ==
Field in show mode


Exceptions are handled by themselves using the errorRegistration(Exception e) method.
[[File:FieldTokenMailto_show.png]]


In case the errors are not caught by the codeunit itself, the generic error handler takes over
Due to its nature this field has no special editing mode.
# Logs the error in the eventlog
# Returns a standard error page to the user


Other debugging options include log4j and specialized TempusServa '''Systemout.print''' functions (yes, the class name is "Systemout").
User interface as displayed in picture


  Systemout.println( "hello world" );
  Systemout.printSql( myStatment );


== Configuration / parameters ==
== Configuration ==
This field requires configuration before deployment.


Parameters are delivered through the method call, packed in a nice <String> Hashtable for easy access.
[[File:FieldCodeunitPage_BE.png]]
Please note that values are sent as-is, so make sure to escape values before DB operations using


  DbConnection.escapeSql(String s);
Required:
* ''As shown above''


Configurations can be stored using the getConfiguration methods of the command object. These values can be editedthrough the designer, depending on the Codeunit type
Options:
* ''As shown above''


* System configurations: Designer > Modules > Static content
== Ajax subforms ==
* Solution configurations: Designer > [Solution] > Advanced > Configurations
The following code changes subform behavior to call the codeunit silently and reload the page when done


Value names will be prefixed with Class simple name - example + "."
  $(function() {
    $('#VB_DATA_SUBFORM a.codeunitButton').click( function(e) {
      e.preventDefault();
      $.get( $(this).attr("href") );
      //$(this).parent().parent().hide();
      location.reload();
      return false;
    });
  });


  '''dk.tempusserva.MyExampleCodeunit.'''myParameter
== Developer info ==
 
* FeltTypeID: 750
== Session variables ==
* SQL datatype: Special
 
* Class name: FieldCodeunitPage
Variables can have a cope of either
* Request
* User session
* Application
 
For permanent variables user server configurations.
 
=== Request variables ===
 
 
=== User session variables ===
Acces the '''SessionValue''' attribute in  the '''Security''' object
* public boolean hasSessionValue(String name)
* public void setSessionValue(String name, boolean value)
* public int getSessionInteger(String name, int defaultValue)
* public int getSessionInteger(String name)
* public void setSessionInteger(String name, int value)
* public String getSessionString(String name, String defaultValue)
* public String getSessionString(String name)
* public void setSessionString(String name, String value)
 
Certain special user properties can also be accessed from the '''Security''' object
* public boolean hasProperty(String name)   
* public String getProperty(String name)
 
=== Application variables ===
 
== Different codeunit types ==
 
Please read the: [[Codeunit reference]]
 
Most likely you will need to create a [[Codeunit/Formevents]] that will allow specific changes for a solution, during views, updates or exports.
 
Most interactions wil require interaction with the following objects
* Security
* Command
* DbConnection
* EventHandler

Latest revision as of 12:51, 10 December 2021

Button: Codeunit execution

Execute proprietary code

Properties

  • Type: Action button
  • Groupable: No
  • Show in lists: No
  • Searchable: No


User interface

Field in show mode

FieldTokenMailto show.png

Due to its nature this field has no special editing mode.

User interface as displayed in picture


Configuration

This field requires configuration before deployment.

FieldCodeunitPage BE.png

Required:

  • As shown above

Options:

  • As shown above

Ajax subforms

The following code changes subform behavior to call the codeunit silently and reload the page when done

 $(function() {
   $('#VB_DATA_SUBFORM a.codeunitButton').click( function(e) { 
     e.preventDefault(); 
     $.get( $(this).attr("href") );
     //$(this).parent().parent().hide();
     location.reload();
     return false; 
   });
 });

Developer info

  • FeltTypeID: 750
  • SQL datatype: Special
  • Class name: FieldCodeunitPage