File: eaf_n_cst_htmldwservice.sru
Size: 55210
Date: Tue, 22 Jan 2008 23:40:13 +0100
$PBExportHeader$eaf_n_cst_htmldwservice.sru
forward
global type eaf_n_cst_htmldwservice from n_cst_contentproviderservice
end type
end forward

global type eaf_n_cst_htmldwservice from n_cst_contentproviderservice
end type
global eaf_n_cst_htmldwservice eaf_n_cst_htmldwservice

type prototypes


end prototypes

type variables
protected:

string            is_webdwstyle

end variables

forward prototypes
protected function string escapequotes (readonly string as_instring)
protected function long setbrowser (ref n_datastore ads_target, string as_browsername)
protected function long setevents (ref n_datastore ads_target, readonly boolean ab_events)
protected function long setform (ref n_datastore ads_target, boolean ab_form)
protected function long setformatting (ref n_datastore ads_target, readonly boolean ab_formatting)
protected function long sethtmlready (ref n_datastore ads_target)
protected function long setpagesize (ref n_datastore ads_target, long al_pagesize)
protected function long setscriptable (ref n_datastore ads_target, boolean ab_scriptable)
protected function long setvalidation (ref n_datastore ads_target, readonly boolean ab_validation)
protected function long setbuttons (ref n_datastore ads_target, string as_buttons)
public function long generate (n_datastore ads_data, ref string as_html)
protected function long setcolumnlink (ref n_datastore ads_target, readonly string as_columnname, readonly string as_link, readonly string as_linkargs, readonly string as_linktarget)
protected function long setcolumnlink (ref n_datastore ads_target, string as_columnlink)
protected function long setselflink (ref n_datastore ads_target, readonly string as_selflink, readonly string as_selflinkargs)
protected function long sethtmlobjectname (ref n_datastore ads_target, string as_objectname)
public function long createcontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset)
public function long preparecontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset, ref n_cst_dataset anv_dataset)
protected function long setclientcomputedfields (ref n_datastore ads_target, boolean ab_clientcomputedfields)
protected function long settabindexbase (ref n_datastore ads_target, readonly long al_tabindexbase)
public function string escapeselflinkargs (string as_original)
end prototypes

protected function string escapequotes (readonly string as_instring);////////////////////////////////////////////////////////////////
// Description:
//    Put in escape quotes to the passed in string
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_instring - The input string
// Returns:
//     The output string
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "escapeQuotes ( string )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
long     ll_inpos
long     ll_outpos = 1
long     ll_length
char     lch_inChars[]
char     lch_outChars[]
char     lch_inChar

// Put the input string into an array of characters
lch_inChars = as_inString;

// Loop around the input string adding the Scape Quotes
ll_length = UpperBound(lch_inChars)
For ll_inpos = 1 To ll_length
   lch_inChar = lch_inChars[ll_inpos]
   
   If lch_inChar = "~~" Then
      lch_outChars[ll_outpos] = "~~"
      lch_outChars[ll_outpos+1] = "~~"
      ll_outpos += 2
   Elseif lch_inChar = "~"" Then
      lch_outChars[ll_outpos] = "~~"
      lch_outChars[ll_outpos+1] = "~""
      ll_outpos += 2
   ElseIf lch_inChar = "'" Then
      lch_outChars[ll_outpos] = "~~"
      lch_outChars[ll_outpos+1] = "'"
      ll_outpos += 2
   Else
      lch_outChars[ll_outpos] = lch_inChar
      ll_outpos++
   End If
Next

Return lch_outChars

end function

protected function long setbrowser (ref n_datastore ads_target, string as_browsername);////////////////////////////////////////////////////////////////
// Description:
//    Set the browser associated with the request on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    as_browsername - The browser associated with the reques
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setBrowser ( REF n_datastore, string )"

inv_log.traceLog (METHOD_NAME, "")

inv_log.detailedLog( METHOD_NAME, inv_constants.MESSAGE_TYPE_EAF_DEBUG, as_browsername )

// Declare local variables
string   ls_modify
string   ls_result = ""

// Perform cleanup
as_browsername = Trim(as_browsername)

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(as_browsername) or Len(as_browsername)=0 Then
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.Browser='" + escapeQuotes(as_browsername) + "'"
ls_result = ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1


end function

protected function long setevents (ref n_datastore ads_target, readonly boolean ab_events);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Event attributes on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    ab_events - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setEvents  ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(ab_events) Then
   addError(METHOD_NAME, "Invalid ab_events argument")   
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.ClientEvents='" + String(ab_events) + "'"
ls_result += ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1

end function

protected function long setform (ref n_datastore ads_target, boolean ab_form);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Form attribute on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    ab_form - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setForm ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modifyString
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(ab_form) Then
   addError(METHOD_NAME, "Invalid ab_form argument")  
   Return -1
End If

// If not allowing form, put into print preview mode
If Not ab_form Then
   ls_modifyString = "DataWindow.print.preview=true"
   ls_result = ads_target.Modify(ls_modifyString)
End If

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long setformatting (ref n_datastore ads_target, readonly boolean ab_formatting);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Formatting attribute on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    ab_formatting  - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setFormatting ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(ab_formatting) Then
   addError(METHOD_NAME, "Invalid ab_formatting argument")
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.ClientFormatting='" + String(ab_formatting) + "'"
ls_result += ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long sethtmlready (ref n_datastore ads_target);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up HTML Ready attributes on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target  - The target datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setHtmlReady ( REF datastore )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmldw='yes' DataWindow.NoUserPrompt='yes'"
ls_result = ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long setpagesize (ref n_datastore ads_target, long al_pagesize);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Page Size attribute on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    al_pagesize - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setPageSize ( REF n_datastore, long )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string ls_modify
string ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(al_pagesize) Then
   addError(METHOD_NAME, "Invalid al_pagesize argument") 
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.PageSize='" + String(al_pagesize) + "'"
ls_result = ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long setscriptable (ref n_datastore ads_target, boolean ab_scriptable);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Scriptable attribute on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    ab_scriptable  - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setScriptable ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(ab_scriptable) Then
   addError(METHOD_NAME, "Invalid ab_scriptable argument")  
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.ClientScriptable='" + String(ab_scriptable) + "'"
ls_result = ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long setvalidation (ref n_datastore ads_target, readonly boolean ab_validation);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Validation attributes on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    ab_validation  - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setValidation ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(ab_validation) Then
   addError(METHOD_NAME, "Invalid ab_validation argument")  
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.ClientValidation='" + String(ab_validation) + "'"
ls_result += ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long setbuttons (ref n_datastore ads_target, string as_buttons);////////////////////////////////////////////////////////////////
// Description:
//    As reqested creates datawindow buttons on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    as_buttons     - The buttons to be created
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setButtons ( REF n_datastore, string )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string                        ls_buttons[]
long                          ll_idx
long                          ll_upper
long                          ll_rc
long                          ll_method_rc = 1
long                          ll_languageid
real                          lr_position
      
n_cst_datastoreservice        lnv_dssrv
n_cst_stringservice           lnv_string

try
   // Perform cleanup
   as_buttons = trim(as_buttons)
   
   // Validate arguments
   If isNull(ads_target) Or Not isValid(ads_target) Then
      addError(METHOD_NAME, "Invalid ads_target argument")
      Return -1
   End If
   
   If isNull(as_buttons) Or len(as_buttons) = 0 Then
      addError(METHOD_NAME, "Invalid as_buttons argument")  
      Return -1
   End If   
   
   // Get the desired language ID
   ll_languageid = ads_target.getLanguageId()
   
   //create the datastore service
   lnv_dssrv = create n_cst_datastoreservice
   inv_log.propagateSettings( lnv_dssrv )
   lnv_dssrv.setRequestor(ads_target)

   //create the string service
   lnv_string = create n_cst_stringservice
   inv_log.propagateSettings( lnv_string )

   // Parse the string into an array for easy processing
   lnv_string.parseStringToArray( as_buttons, ',' ,ls_buttons)
   
   // Loop around the newly created array creating the requested buttons
   ll_upper = upperBound(ls_buttons)
   For ll_idx = 1 To ll_upper
      ls_buttons[ll_idx] = trim(lower(ls_buttons[ll_idx]))
      // Hanle the "gap" button keyword
      If pos(ls_buttons[ll_idx], "gap") > 0 Then
         Choose Case ls_buttons[ll_idx]
            Case "gap075"
               lr_position += 0.75           
            Case "gap050"
               lr_position += 0.50
            Case "gap025"
               lr_position += 0.25
            Case "gap015"
               lr_position += 0.15           
            Case "gap010"
               lr_position += 0.10           
            Case Else
               lr_position ++
         End Choose
         Continue
      Else
         lr_position ++
      End If      
      
      ll_rc = lnv_dssrv.createButton( ls_buttons[ll_idx], lr_position, ll_languageid)
      If ll_rc < 0 Then ll_method_rc = -1
   Next
finally
   if isValid( lnv_dssrv ) then
      destroy lnv_dssrv
   end if
   
   if isValid( lnv_string ) then
      destroy lnv_string
   end if
end try

Return ll_method_rc
end function

public function long generate (n_datastore ads_data, ref string as_html);////////////////////////////////////////////////////////////////
// Description:
//    Generate the HTML
// Revisions
//    1.0   - Initial version
//    2.0   - Added special Logging for this critical point
// Arguments:  
//    ads_data    - The datastore containing the data
//    as_html     - The generated HTML being passed back
// Returns:
//     The output string
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "generate( REF n_datastore, ref string ) "

inv_log.traceLog (METHOD_NAME, "(ads_data, ref as_html)")

// Validate arguments
If isNull(ads_data) Or Not isValid(ads_data) Then
   addError(METHOD_NAME, "Invalid ads_data argument")
   Return -1
End If

Choose Case is_webdwstyle
   Case inv_constants.WEBDW_STYLE_HTML
      as_html = ads_data.Describe("DataWindow.Data.HTML")
   Case inv_constants.WEBDW_STYLE_XHTML
      as_html = ads_data.Describe("DataWindow.Data.XHTML")
   Case inv_constants.WEBDW_STYLE_XML
      as_html = ads_data.Describe("DataWindow.Data.XMLWeb")
End Choose

inv_log.debugLog( METHOD_NAME, inv_constants.MESSAGE_TYPE_EAF_DEBUG, "Generated "  + is_webdwstyle + " Web DataWindow content" )

Return 1

end function

protected function long setcolumnlink (ref n_datastore ads_target, readonly string as_columnname, readonly string as_link, readonly string as_linkargs, readonly string as_linktarget);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up the Column Link attributes on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    as_columnname  - Column to set the link on
//    as_link        - Link to be set
//    as_linkargs    - Arguments for the link
//    as_linktarget  - Target frame
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setColumnLink  ( REF n_datastore, string, string, string, string )"

inv_log.traceLog (METHOD_NAME, "" )

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If

// Assign the attributes
If Not IsNull(as_columnName) Then
   If Not IsNull(as_link) And Trim(as_link) <> "" Then
      ls_modify = as_columnName + ".HTML.Link='" + escapeQuotes(as_link) + "'"
      ls_result = ads_target.Modify(ls_modify)
   End If
   
   If Not IsNull(as_linktarget) And trim(as_link) <> "" Then
      ls_modify = as_columnName + ".HTML.LinkTarget='" + escapeQuotes(as_linktarget) + "'"
      ls_result += ads_target.Modify(ls_modify)
   End If

   If Not IsNull(as_linkargs)  And trim(as_linkargs) <> "" Then
      ls_modify = as_columnName + ".HTML.LinkArgs=~"" + escapeQuotes(as_linkargs) + "~""
      ls_result += ads_target.Modify(ls_modify)
   End If
End If

If len(ls_result) > 0 Then
   addError(METHOD_NAME, "Error on modify: "+ls_result)
   Return -1
End If

Return 1


end function

protected function long setcolumnlink (ref n_datastore ads_target, string as_columnlink);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up the Column Link attributes on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    as_columnlink - preformatted column link 
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setColumnLink  ( REF n_datastore, string )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
long                    ll_method_rc
long                    ll_idx
long                    ll_upper
long                    ll_entrycount
long                    ii_entryidx
string                  ls_linklist[]
string                  ls_arglist[]

n_cst_stringservice     lnv_string

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(as_columnlink) Then
   addError(METHOD_NAME, "Invalid astr_columnlink argument")
   Return -1
End If

try
   //create the string service
   lnv_string = create n_cst_stringservice
   inv_log.propagateSettings( lnv_string )
   
   // Set column links
   lnv_string.parsestringtoarray ( as_columnlink, '!!', ls_linklist )
   ll_upper = upperBound(ls_linklist)
   For ll_idx = 1 To ll_upper
      lnv_string.parsestringtoarray ( ls_linklist[ll_idx], '^^', ls_arglist )
      ll_entrycount = upperbound(ls_arglist)
      if ll_entrycount < 2 then exit //must have at least two parameters
      for ii_entryidx = ll_entrycount + 1 to 4
         ls_arglist[ii_entryidx] = ""
      next
      
      // Stop processing when first has instance has zero length string for column name
      If ls_arglist[1] = "" Then
         exit
      End If
      If setColumnLink( ads_target,ls_arglist[1],ls_arglist[2], ls_arglist[3], ls_arglist[4] ) = -1 Then
         addError(METHOD_NAME, "Failed setColumnLink() operation ll_idx="+string(ll_idx))
         ll_method_rc = -1
      End If
   Next
finally
   if isValid( lnv_string ) then
      destroy lnv_string
   end if
end try

Return ll_method_rc


end function

protected function long setselflink (ref n_datastore ads_target, readonly string as_selflink, readonly string as_selflinkargs);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up Self Link attributes on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    as_selflink - link URL
//    as_selflinkargs - Link arguments
// Returns:
//     
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setSelfLink ( REF n_datastore, RO string, RO string  )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""
string   ls_method_rc = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
End If

If Not IsNull(as_selflink) and as_selflink <> "" Then
   ls_modify = "DataWindow.htmlgen.SelfLink='" + escapeQuotes (as_selflink) + "'"
   ls_result = ads_target.Modify(ls_modify)
End If

If Not IsNull(as_selflinkargs) Then
   ls_modify = "DataWindow.htmlgen.SelfLinkArgs=~"" + escapeSelfLinkArgs(as_selflinkargs) + "~""
   ls_result += ads_target.Modify(ls_modify)
End If

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long sethtmlobjectname (ref n_datastore ads_target, string as_objectname);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up HTML Object Name attribute on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    as_objectname  - The attribute value to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setHtmlObjectName ( REF n_datastore, string )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result

// Perform cleanup
as_objectname = trim(as_objectname)

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError (METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If
If isNull(as_objectname) Or Len(as_objectname) = 0 Then
   addError (METHOD_NAME, "Invalid as_objectname argument")
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.ObjectName='" + escapeQuotes (as_objectname) + "'"
ls_result = ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1



end function

public function long createcontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset);////////////////////////////////////////////////////////////////
// Description:
//    Main method in createContent process
// Revisions
//    3.0   - Initial version
// Arguments:  
//    n_cst_datasetattrib  -  REF
//    s_mimerequest        -  REF
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

string METHOD_NAME = "createContentMain( REF n_cst_datasetattrib, REF s_mimedataset )"
String ls_text, ls_selflink
n_cst_stringservice lnvo_string
Long ll_row

try
   
   if generate( anv_datasetattrib.ids_working, ls_text) = -1 then
      //set error message
      addError( METHOD_NAME, "Failed to create HTML content.  generate() failed." )
      return -1
   else
      
      //?? PB11 BUG: picture object rendering error
      //Workaround: replace image path
      if Pos(ls_text, "IMG SRC=") > 0 then
         lnvo_string = create n_cst_stringservice
         anv_datasetattrib.inv_argumentservice.GetArgument(inv_constants.EAF_SELF_LINK_ARGUMENT_NAME, ls_selflink)
         ls_selflink = Left(ls_selflink, Pos(ls_selflink, "/", 2))
         ls_text = lnvo_string.globalreplace( ls_text, '<IMG SRC="/' + GetApplication().AppName + '/pbopenfile.aspx?t=0&o=1&e=0&c=images%5c', '<IMG SRC="' + ls_selflink + "images/", true)
         destroy lnvo_string
      end if
      
      //Workaround: add id and name
      //rowindicator
      if Pos(ls_text, "rowindicator") > 0 and anv_datasetattrib.ids_working.RowCount() > 0 then
         for ll_row = 0 to anv_datasetattrib.ids_working.RowCount() - 1
            lnvo_string = create n_cst_stringservice
            ls_text = lnvo_string.globalreplace( ls_text, String(ll_row) + ",-1,'rowindicator',0,-1);}", String(ll_row) + ",-1,'rowindicator',0,-1);}" + '";id="rowindicator_' + String(ll_row) + '" name="rowindicator_'+ String(ll_row) + '"', true)
            destroy lnvo_string
         next
      end if
      
      astr_mimedataset.data.text = ls_text
   end if
   
finally

end try


Return 1

end function

public function long preparecontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset, ref n_cst_dataset anv_dataset);////////////////////////////////////////////////////////////////
// Description:
//    Main method in prepareContent process
// Revisions
//    3.0   - Initial version
// Arguments:  
//    n_cst_datasetattrib  -  REF
//    s_mimerequest        -  REF
//    anv_dataset          -  REF
// Returns: 
//     1 - Success
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "prepareContentMain (REF n_cst_datasetattrib, REF s_mimedataset, REF n_cst_dataset)"

// Declare local variables
long                             ll_rc
string                           ls_error
boolean                          lb_usejavascriptcaching =  true
boolean                          lb_usenetscapelayers =     true
string                           ls_variablename
string                           ls_publishpathvariablename
string                           ls_resourcebasevariablename
string                           ls_version
string                           ls_value
string                           ls_selflinkarguments
boolean                          lb_ignorebrowsertype
string                           ls_action
string                           ls_context
string                           ls_linkobject
string                           ls_linkurl
string                           ls_linkarguments
string                           ls_linktarget
string                           ls_links[]
long                             ll_linkcount
long                             ll_linkindex
int                              li_pbversion
string                           ls_holder[]
string                           ls_linksxml[]
string                           ls_staticjsresourcebase
string                           ls_resourcebase
string                           ls_publishpath
string                           ls_websitepath
string                           ls_runtimeerror
string                           ls_selflinkdir
n_cst_VariableManager            lnv_variablemanager

n_cst_stringservice              lnv_string
n_cst_xmlparser                  lnv_parser
n_cst_objectservice              lnv_objectservice

try
      
   lnv_string = create n_cst_stringservice
   lnv_objectservice = create n_cst_objectservice

   //Get handle to VariableManager component
   lnv_variablemanager = create using inv_constants.VARIABLE_MANAGER_COMPONENT_NAME

   //Get the Web DW Style Requested
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_WEBDW_STYLE_ARGUMENT_NAME, is_webdwstyle ) = -1 then
      is_webdwstyle = inv_constants.WEBDW_STYLE_HTML
   end if

   //See if JavaScript caching has been specifically disabled
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_USE_JAVASCRIPT_CACHING_ARGUMENT_NAME, ls_value ) = 1 then
      lb_usejavascriptcaching = lnv_string.toBoolean( ls_value )
   end if
   
   //See if Netscape Layers capability has been specifically disabled
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_USE_NETSCAPE_LAYERS_ARGUMENT_NAME, ls_value ) = 1 then
      lb_usenetscapelayers = lnv_string.toBoolean( ls_value )
   end if

   //Get the Action
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_ACTION_ARGUMENT_NAME, ls_action ) = -1 then
      ls_action = ""
   end if
   
   //Get the Context - not required in the case of retrieves
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_CONTEXT_ARGUMENT_NAME, ls_context ) = -1 then
      ls_context = ""
   end if

   if isNull(ls_action) then
      ls_action = ""
   end if
   
   if isNull(ls_context) then
      ls_context = ""
   end if

   inv_log.debugLog( METHOD_NAME, inv_constants.MESSAGE_TYPE_EAF_DEBUG, "Action(" + anv_datasetattrib.is_name + "): " + ls_action )
   inv_log.debugLog( METHOD_NAME, inv_constants.MESSAGE_TYPE_EAF_DEBUG, "Context(" + anv_datasetattrib.is_name + "): " + ls_context )
   
   //Process retrieve if an update
   if not anv_datasetattrib.ib_retrieved then
      //Process DropDownDataWindows
      if anv_dataset.retrieveChildren(anv_datasetattrib) = -1 then
         addError( METHOD_NAME, "Child DataWindow population failed for DataSet " + anv_datasetattrib.is_name )
         return -1
      end if
      
      // Request the Retrieve operation
      if anv_dataset.retrieve( anv_datasetattrib) = -1 then
         inv_messaging.append( anv_dataset.inv_messaging )
         addError( METHOD_NAME, "Failed due to anv_dataset.retrieve() failure." )
         return -1
      end if
   end if

   //Browser Type
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_IGNORE_BROWSER_TYPE_ARGUMENT_NAME, ls_value ) = 1 then
      lb_ignorebrowsertype = lnv_string.toBoolean( ls_value )
   end if

   if not lb_ignorebrowsertype then 
      if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_BROWSER_TYPE_ARGUMENT_NAME, ls_value ) = 1 then
         If setBrowser( anv_datasetattrib.ids_working, ls_value ) = -1 Then
            addError(METHOD_NAME, "Failed to create HTML content.  setBrowser() failed.")
            return -1
         End If
      End If      
   End If   
   
   //Column Links
   lnv_parser = create n_cst_xmlparser
   lnv_parser.getElementList( astr_mimedataset.arguments, inv_constants.EAF_LINKS_ELEMENT_NAME, ls_linksxml )  
   if upperBound( ls_linksxml ) > 0 then
      lnv_parser.getElementList( ls_linksxml[1], inv_constants.EAF_LINK_ELEMENT_NAME, ls_links )
      ll_linkcount = upperBound( ls_links )
      for ll_linkindex = 1 to ll_linkcount
         lnv_parser.getElementList( ls_links[ll_linkindex], inv_constants.EAF_LINK_OBJECT_ELEMENT_NAME, ls_holder )
         ls_linkobject = ls_holder[1]
         lnv_parser.getElementList( ls_links[ll_linkindex], inv_constants.EAF_LINK_URL_ELEMENT_NAME, ls_holder )
         ls_linkurl = ls_holder[1]
         lnv_parser.getElementList( ls_links[ll_linkindex], inv_constants.EAF_LINK_ARGUMENTS_ELEMENT_NAME, ls_holder )
         ls_linkarguments = ls_holder[1]
         lnv_parser.getElementList( ls_links[ll_linkindex], inv_constants.EAF_LINK_TARGET_ELEMENT_NAME, ls_holder )
         ls_linktarget = ls_holder[1]

         If setColumnLink( anv_datasetattrib.ids_working, ls_linkobject, ls_linkurl, ls_linkarguments, ls_linktarget ) = -1 Then
            addError(METHOD_NAME, "Failed to create HTML content.  setColumnLink() failed: Object: '" + ls_linkobject + "' URL: '" + ls_linkurl + "' Arguments: '" + ls_linkarguments + "' Target: '" + ls_linktarget + "'")                 
            return -1
         End If
      next
   End If
   
   //Netscape layers
   if lb_usenetscapelayers then
      ls_error = anv_datasetattrib.ids_working.modify  ("DataWindow.HTMLGen.NetscapeLayers='YES'")
      if ls_error <> '' then
         addError(METHOD_NAME, "DataWindow.HTMLGen.NetscapeLayers='YES', "+ls_error)
         Return -1
      end if
   end if
   
   //Set name for HTML generation
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_DW_CONTROL_NAME_ARGUMENT_NAME, ls_value ) = 1 then
      If setHtmlObjectName( anv_datasetattrib.ids_working, ls_value ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setHtmlObjectName() failed.")
         Return -1
      End If
   end if

   //Set HTML Ready
   If setHtmlReady(anv_datasetattrib.ids_working) = -1 Then
      addError(METHOD_NAME, "Failed to create HTML content.  setHtmlReady() failed.")
      Return -1
   End If
   
   //Script
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_SCRIPT_CAPABILITY_ARGUMENT_NAME, ls_value ) = 1 then
      If setScriptable( anv_datasetattrib.ids_working, lnv_string.toBoolean( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setScriptable() failed.")    
         return -1
      End If
   End If   

   //Events
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_EVENTS_CAPABILITY_ARGUMENT_NAME, ls_value ) = 1 then
      If setEvents( anv_datasetattrib.ids_working, lnv_string.toBoolean( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setEvents() failed.")     
         return -1
      End If
   End If   

   //Formatting
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_FORMATTING_CAPABILITY_ARGUMENT_NAME, ls_value ) = 1 then
      If setFormatting( anv_datasetattrib.ids_working, lnv_string.toBoolean( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setFormatting() failed.")    
         return -1
      End If
   End If   

   //Validation
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_VALIDATION_CAPABILITY_ARGUMENT_NAME, ls_value ) = 1 then
      If setValidation( anv_datasetattrib.ids_working, lnv_string.toBoolean( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setValidation() failed")     
         return -1
      End If
   End If   
   
   //Self Link
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_SELF_LINK_ARGUMENT_NAME, ls_value ) = 1 then
      anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_SELF_LINK_ARGUMENTS_ARGUMENT_NAME, ls_selflinkarguments )
      If setSelfLink( anv_datasetattrib.ids_working, ls_value, ls_selflinkarguments ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setSelfLink() failed: URL: '" + ls_value + "' Arguments: '" + ls_selflinkarguments + "'")      
         return -1
      End If
      ls_selflinkdir = Left(ls_value, Pos(ls_value, "/", 2))
   End If   
   
   //Page Size
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_PAGE_SIZE_ARGUMENT_NAME, ls_value ) = 1 then
      If setPageSize ( anv_datasetattrib.ids_working, Long( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setPageSize() failed. Page size: " + ls_value)
         return -1
      End If
   End If   
   
   //Buttons
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_BUTTONS_ARGUMENT_NAME, ls_value ) = 1 then
      If setButtons ( anv_datasetattrib.ids_working, ls_value ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content. setButtons() failed.  Buttons '" + ls_value + "'")       
         return -1
      End If
   End If
   
   //Client Computed Fields
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_CLIENT_COMPUTED_FIELDS_ARGUMENT_NAME, ls_value ) = 1 then
      If setClientComputedFields( anv_datasetattrib.ids_working, lnv_string.toBoolean( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to create HTML content.  setClientComputedFields() failed")    
         return -1
      End If
   End If
   
   //TabIndexBase
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.EAF_TAB_INDEX_BASE_ARGUMENT_NAME, ls_value ) = 1 then
      If setTabIndexBase ( anv_datasetattrib.ids_working, long( ls_value ) ) = -1 Then
         addError(METHOD_NAME, "Failed to set tab index base with value '" + ls_value + "'")       
         return -1
      End If
   End If
   
   //Get the location of EAServer or IIS ASP.NET
   IF lnv_objectservice.getEnvironmentVariable( "JAGUAR", ls_websitepath ) = -1 then
      ls_websitepath = ls_selflinkdir
   end if
   if ls_websitepath = "" then
      addError(METHOD_NAME, "Could not determine the value of the JAGUAR environment path or IIS ASP.NET path")
      Return -1
   end if
   
   //Get the PB Version
   lnv_objectservice.getPBVersion( li_pbversion )
   
   //Get the version of PowerBuilder being used
   Choose Case li_pbversion
      Case 11
         ls_variablename = inv_constants.HTMLDW_110_JS_LOCATION_VARIABLE_NAME
   End Choose

   //Get the resource base for the static Javascript files
   lnv_variablemanager.getValue( ls_variablename, ls_staticjsresourcebase )
   if ls_staticjsresourcebase = "" or IsNull(ls_staticjsresourcebase) then
      ls_staticjsresourcebase = ls_websitepath + "scripts"
   else
      ls_staticjsresourcebase = lnv_string.globalReplace( ls_staticjsresourcebase, "%WEBSITE%", ls_websitepath, true )  
   end if
   ls_error = anv_datasetattrib.ids_working.modify("datawindow.htmlgen.resourcebase='"+ ls_staticjsresourcebase +"'")
   if ls_error <> '' then
      addError(METHOD_NAME, "Error on datawindow.htmlgen.resourcebase='" + ls_staticjsresourcebase + "', "+ls_error)
      Return -1
   end if

   //Set the static Javascript file names
   ls_error = anv_datasetattrib.ids_working.modify("datawindow.htmlgen.CommonJSFile='dwcommon.js'  datawindow.htmlgen.DateJSFile='dwdatetime.js'  datawindow.htmlgen.NumberJSFile='dwnumber.js' datawindow.htmlgen.StringJSFile='dwstring.js'")
   if ls_error <> '' then
      addError(METHOD_NAME, "Error on setting javascript caching include file locations, "+ls_error)
      Return -1
   end if
   
   //Set the static User Javascript file names
   if anv_datasetattrib.inv_argumentservice.getArgument( inv_constants.WEBDW_JS_USER_JSFILE_VARIABLE_NAME, ls_value ) = 1 then
      if ls_value <> "" then
         ls_error = anv_datasetattrib.ids_working.modify("datawindow.htmlgen.UserJSFile='" + ls_value + "'")
         if ls_error <> '' then
            addError(METHOD_NAME, "Error on setting User javascript caching include file locations, "+ls_error)
            Return -1
         end if
      end if
   End If
   
   //Shared Publish Paths and Resource Bases for XHTML and XML Web DataWindows
   if is_webdwstyle = inv_constants.WEBDW_STYLE_XHTML or is_webdwstyle = inv_constants.WEBDW_STYLE_XML then
      
      //Set the SessionSpecific property
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.cssgen.sessionspecific='yes'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.cssgen.sessionspecific='yes', "+ls_error)
         Return -1
      end if
      
      //CSS Publish Path
      lnv_variablemanager.getValue( inv_constants.WEBDW_CSS_PUBLISH_PATH_VARIABLE_NAME, ls_publishpath )
      ls_publishpath = lnv_string.globalReplace( ls_publishpath, "%WEBSITE%", ls_websitepath, true )  
      
      if ls_publishpath = "" then
         ls_publishpath = ls_websitepath + "css"
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.cssgen.publishpath='" + ls_publishpath + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.cssgen.publishpath='" + ls_publishpath + "', "+ls_error)
         Return -1
      end if
      
      //CSS Resource Base
      lnv_variablemanager.getValue( inv_constants.WEBDW_CSS_RESOURCE_BASE_VARIABLE_NAME, ls_resourcebase )
      if ls_resourcebase = "" then
         ls_resourcebase = ls_websitepath + "css"
      else
         ls_resourcebase = lnv_string.globalReplace( ls_resourcebase, "%WEBSITE%", ls_websitepath, true )   
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.cssgen.resourcebase='" + ls_resourcebase + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.cssgen.resourcebase='" + ls_resourcebase + "', "+ls_error)
         Return -1
      end if

      //JS Publish Path
      lnv_variablemanager.getValue( inv_constants.WEBDW_JS_PUBLISH_PATH_VARIABLE_NAME, ls_publishpath )
      ls_publishpath = lnv_string.globalReplace( ls_publishpath, "%WEBSITE%", ls_websitepath, true )
      
      if ls_publishpath = "" then
         ls_publishpath = ls_websitepath + "scripts"
         ls_publishpath = lnv_string.globalreplace( ls_publishpath, "/", "\\", true)
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.jsgen.publishpath='" + ls_publishpath + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.jsgen.publishpath='" + ls_publishpath + "', "+ls_error)
         Return -1
      end if

      //JS Resource Base
      lnv_variablemanager.getValue( inv_constants.WEBDW_JS_RESOURCE_BASE_VARIABLE_NAME, ls_resourcebase )
      if ls_resourcebase = "" then
         ls_resourcebase = ls_websitepath + "scripts"
      else
         ls_resourcebase = lnv_string.globalReplace( ls_resourcebase, "%WEBSITE%", ls_websitepath, true )   
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.jsgen.resourcebase='" + ls_resourcebase + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.jsgen.resourcebase='" + ls_resourcebase + "', "+ls_error)
         Return -1
      end if
   end if
   
   //Publish Paths and Resource Bases for the XML Web DataWindow
   if is_webdwstyle = inv_constants.WEBDW_STYLE_XML then
      //XML Publish Path
      lnv_variablemanager.getValue( inv_constants.WEBDW_XML_PUBLISH_PATH_VARIABLE_NAME, ls_publishpath )
      ls_publishpath = lnv_string.globalReplace( ls_publishpath, "%WEBSITE%", ls_websitepath, true )
      
      if ls_publishpath = "" then
         ls_publishpath = ls_websitepath + "xml"
         ls_publishpath = lnv_string.globalreplace( ls_publishpath, "/", "\\", true)
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.xmlgen.publishpath='" + ls_publishpath + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.xmlgen.publishpath='" + ls_publishpath + "', "+ls_error)
         Return -1
      end if

      //XML Resource Base
      lnv_variablemanager.getValue( inv_constants.WEBDW_XML_RESOURCE_BASE_VARIABLE_NAME, ls_resourcebase )
      if ls_resourcebase = "" then
         ls_resourcebase = ls_websitepath + "xml"
      else
         ls_resourcebase = lnv_string.globalReplace( ls_resourcebase, "%WEBSITE%", ls_websitepath, true )   
      end if
         
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.xmlgen.resourcebase='" + ls_resourcebase + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.xmlgen.resourcebase='" + ls_resourcebase + "', "+ls_error)
         Return -1
      end if
      
      //XSL Publish Path
      lnv_variablemanager.getValue( inv_constants.WEBDW_XSL_PUBLISH_PATH_VARIABLE_NAME, ls_publishpath )
      ls_publishpath = lnv_string.globalReplace( ls_publishpath, "%WEBSITE%", ls_websitepath, true )
      
      if ls_publishpath = "" then
         ls_publishpath = ls_websitepath + "xsl"
         ls_publishpath = lnv_string.globalreplace( ls_publishpath, "/", "\\", true)
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.xsltgen.publishpath='" + ls_publishpath + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.xsltgen.publishpath='" + ls_publishpath + "', "+ls_error)
         Return -1
      end if

      //XSL Resource Base
      lnv_variablemanager.getValue( inv_constants.WEBDW_XSL_RESOURCE_BASE_VARIABLE_NAME, ls_resourcebase )
      if ls_resourcebase = "" then
         ls_resourcebase = ls_websitepath + "xsl"
      else
         ls_resourcebase = lnv_string.globalReplace( ls_resourcebase, "%WEBSITE%", ls_websitepath, true )   
      end if
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.xsltgen.resourcebase='" + ls_resourcebase + "'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.xsltgen.resourcebase='" + ls_resourcebase + "', "+ls_error)
         Return -1
      end if
      
      //Enable Inline Generation
      ls_error = anv_datasetattrib.ids_working.modify("datawindow.xmlgen.inline='true'")
      if ls_error <> '' then
         addError(METHOD_NAME, "Error on datawindow.xmlgen.inline='true'', "+ls_error)
         Return -1
      end if
   end if

   //Set the Action and Context from the Web DataWindow
   ll_rc = anv_datasetattrib.ids_working.setHTMLAction( ls_action, ls_context, false)
   If ll_rc < 0 then
      inv_messaging.append( anv_datasetattrib.ids_working.inv_messaging )
      addError( METHOD_NAME, "Failed to create content.  setHTMLAction() failed.")  
      Return -1
   End If
   
catch ( RuntimeError re )
   
   ls_runtimeerror = "Runtime Error:" + inv_constants.CRLF + inv_constants.CRLF
   ls_runtimeerror += "Error Code: " + string(re.number) + inv_constants.CRLF
   ls_runtimeerror += "Object: " + re.objectName + inv_constants.CRLF
   ls_runtimeerror += "Class: " + re.class + inv_constants.CRLF
   ls_runtimeerror += "Function/Event: " + re.routineName + inv_constants.CRLF
   ls_runtimeerror += "Line: " + string(re.line) + inv_constants.CRLF
   ls_runtimeerror += "Message: " + re.getMessage() + inv_constants.CRLF
   
   addError( METHOD_NAME, "Runtime Error: " + ls_runtimeerror )

finally
   if ( isValid( lnv_objectservice ) ) then
      destroy lnv_objectservice
   end if
   if ( isValid( lnv_string ) ) then
      destroy lnv_string
   end if
   if ( isValid( lnv_parser ) ) then
      destroy lnv_parser
   end if
   
   if isValid(lnv_variablemanager) then
      destroy lnv_variablemanager
   end if
   
end try

Return 1

end function

protected function long setclientcomputedfields (ref n_datastore ads_target, boolean ab_clientcomputedfields);////////////////////////////////////////////////////////////////
// Description:
//    As reqested set up client computed fields attribute on the datastore
// Revisions
//    1.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    ab_scriptable  - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setClientComputedFields ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string   ls_modify
string   ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If

// Assign the attribute
ls_modify = "DataWindow.htmlgen.ClientComputedFields='" + String(ab_clientcomputedfields) + "'"
ls_result = ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1
end function

protected function long settabindexbase (ref n_datastore ads_target, readonly long al_tabindexbase);////////////////////////////////////////////////////////////////
// Description:
//    Sets the Web DataWindow's tab index base
// Revisions
//    4.0   - Initial version
// Arguments:  
//    ads_target     - The target datastore
//    al_tabindexbase - The attribute to be assigned to the datastore
// Returns:
//     1 - Success
//    -1 - Failre
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "setTabIndexBase  ( REF n_datastore, boolean )"

inv_log.traceLog (METHOD_NAME, "")

// Declare local variables
string      ls_modify
string      ls_result = ""

// Validate arguments
If isNull(ads_target) Or Not isValid(ads_target) Then
   addError(METHOD_NAME, "Invalid ads_target argument")
   Return -1
End If

if al_tabindexbase > 32767 then
   addError(METHOD_NAME, "Invalid TabIndexBase.  Must be less than 32768.")
   return -1
end if

// Assign the attribute
ls_modify = "DataWindow.htmlgen.TabIndexBase='" + String(al_tabindexbase) + "'"
ls_result += ads_target.Modify(ls_modify)

If len(ls_result) > 0 Then
   Return -1
End If

Return 1

end function

public function string escapeselflinkargs (string as_original);////////////////////////////////////////////////////////////////
// Description:
//  Put in escape quotes for SelfLinksArgs to the passed in string
// Revisions
//  1.0 - Initial version
// Arguments: 
//  as_original - The input string
// Returns:
//   The output string
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 
String                  METHOD_NAME = "escapeSelfLinkArgs( )"

integer                 li_arg, li_args
string                  ls_outstring
string                  ls_arguments[], ls_argnamevalue[], ls_escapevalue

n_cst_stringservice     lnv_string

try
   lnv_string = create n_cst_stringservice
   
   lnv_string.parsestringtoarray(as_original, "|", ls_arguments)
   li_args = Upperbound(ls_arguments)
   
   For li_arg = 1 To li_args
      // Escape each argument
      lnv_string.parsestringtoarray(ls_arguments[li_arg], '=', ls_argnamevalue)
      ls_escapevalue = Mid(ls_argnamevalue[2], 2, Len(ls_argnamevalue[2]) - 2)
      
      // Value needs to be escaped twice
      ls_escapevalue = escapeQuotes(ls_escapevalue)
      ls_escapevalue = escapeQuotes(ls_escapevalue)
      ls_argnamevalue[2] = Left(ls_argnamevalue[2], 1) + ls_escapevalue + Right(ls_argnamevalue[2], 1)
      
      ls_arguments[li_arg] = ls_argnamevalue[1] + "=" + ls_argnamevalue[2]
   Next
   
   lnv_string.parsearraytostring( ls_arguments, "|", ls_outstring)

finally
   destroy lnv_string
end try

Return ls_outstring

end function

on eaf_n_cst_htmldwservice.create
call super::create
end on

on eaf_n_cst_htmldwservice.destroy
call super::destroy
end on