#1 2015-06-25 21:02:50

fabioquestor
Member
From: Chapecó, SC, Brasil
Registered: 2014-05-19
Posts: 13
Website

I need aSubURI in TMVCApplication.Default

aSubURI is passed in TMVCRunOnRestServer.Create (aApplication: TMVCApplication;
   aRestServer: TSQLRestServer; const aSubURI: RawUTF8;
   aViews: TMVCViewsAbtract; aPublishOptions: TMVCPublishOptions);

I tried the tip in post http://synopse.info/forum/viewtopic.php?id=2136

  Result: = ServiceContext.Request.InHeader ['host'];

but me the av

debug tried but without success.

thank you

very good your framework

Offline

#2 2015-06-26 06:48:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: I need aSubURI in TMVCApplication.Default

I do not understand what is the link between "aSubURI" and "ServiceContext" use.

Is ServiceContext=nil?
Where do you call it?
Do you have some code snippet?

I tried to reproduce your problem, by adding the same code in TBlogApplication.Default, and it works with no issue.

Offline

#3 2015-06-26 17:38:21

fabioquestor
Member
From: Chapecó, SC, Brasil
Registered: 2014-05-19
Posts: 13
Website

Re: I need aSubURI in TMVCApplication.Default

Hello AB

Really the test 30 is working.

But in my not.

What I am doing is a facade layer to my legacy system.

I have the forms of records that would use the url: http: // localhost: 8080 / ntoCadastro / TnGemDMUsuarioGrupoUsu / default

and only have one TnWebServerHTMLCad = class (TSQLRestServerFullMemory)

registered with TnWebServerHTMLCad.Create (TSQLModel.Create ( 'ntoCadastro'));
constructor TnWebServerHTMLCad.Create(aModel: TSQLModel;
  aHandleUserAuthentication: boolean);
begin
  inherited;
  FMVC := TnWebMVCCad.Create;
  FMVC.Start(Self);
end;

procedure TnWebMVCCad.Start(aServer: TSQLRestServer);
var
  aViews: TMVCViewsMustache;
  params: TMVCViewsMustacheParameters;
  i: Integer;
  s: String;

begin
  inherited Start(aServer,TypeInfo(InWebMVCCad));

  fillchar(params,sizeof(params),0);
  params.ExtensionForNotExistingTemplate := '.html';
  params.Helpers := TSynMustache.HelpersGetStandardList;
  params.FileTimestampMonitorAfterSeconds := 5;
  params.Folder := ExeVersion.ProgramFilePath+'Views'+PathDelim+ClassName+PathDelim;

  aViews := TMVCViewsMustache.Create(
    fFactory.InterfaceTypeInfo, params,
  {$ifdef WITHLOG}
      fRestServer.LogClass) else
  aViews.fLogClass := fRestServer.LogClass;
  {$else}
      TSQLLog);
  {$endif}

  fMainRunners := TStringList.Create;;

  for i := 0 to FnActionListDireitos.ActionCount - 1 do
  begin
    if FnActionListDireitos.Actions I .Tag = 1 then
    begin
      s := FnActionListDireitos.Actions I .Name;
      if Pos('npmn', s) = 1 then
        s := Copy(s, 9, MaxInt);

      s := Copy(s, 4, MaxInt);

      if fMainRunners.IndexOf(s) < 0 then
      begin
        fMainRunners.AddObject(s,
          TMVCRunOnRestServer.Create(Self, nil, s, aViews).
            SetCache('Default',cacheRootIfNoSession,15));
      end;
    end;
  end;
end;

"TnGemDMUsuarioGrupoUsu" this is registration of name

By this accuracy to know this information in the method procedure TnWebMVCCad.Default (var Scope: variant);

not like to do http://localhost:8080/ntoCadastro/default?cad=TnGemDMUsuarioGrupoUsu

but it will be the way if not consequir access this information.


actually I do not know how I should structure the class or several classes, TMVCApplication because it would not work with all methods in a TMVCApplication, for this I am well structured.

I have more than 6,000 objects from registration, appointments, processes and reports.

but I will try to do without having to make an html for each object.

I wanted to have a class for each object type.

The main question is how to structure a MVC with many pages (6000+) ????

Last edited by fabioquestor (2015-06-26 18:04:27)

Offline

#4 2015-06-26 17:43:35

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: I need aSubURI in TMVCApplication.Default

Why just not use parameters, so that the page would reflect what you need.

In typical MVC routing, the page details the View to be used, then the parameters and the execution context (cookie) let the Controler retrieve data from the Model to define the data rendered by the View.
So you have one "page" per view, and in mORMot implementation, one method per view.

Offline

#5 2015-06-26 20:02:31

fabioquestor
Member
From: Chapecó, SC, Brasil
Registered: 2014-05-19
Posts: 13
Website

Re: I need aSubURI in TMVCApplication.Default

Thank you, I will do so.

Offline

Board footer

Powered by FluxBB