How to read and understandUrl mapping


#1

Hi,
i am new to scipio framework please help, i am trying to understand, i have gone through the tutorials but it seems i can not still understand… for example when i hit this link on navigation url bar (https://localhost:8443/accounting/control/findArInvoices) i get the page to search for invoices.
But in the controller.xml file i can not see enough information to know where i can get the findArInvoices file so that i can study the logic behind. the conroller have the following information.

<request-map uri="findInvoices">
    <security https="true" auth="true"/>
    <response name="success" type="view" value="findInvoices"/>
</request-map>
<request-map uri="invoiceOverview">
    <security https="true" auth="true"/>
    <response name="success" type="view" value="invoiceOverview"/>
</request-map>
<request-map uri="newInvoice">
    <security https="true" auth="true"/>
    <response name="success" type="view" value="newInvoice"/>
</request-map>



#2

So you got the correct request.

You can see that the response for “success” is a “view” with name “findInvoices”. Check in the same file for a view-map of the same name. It will lead you to the correct screen. This concept is also explained here: https://www.scipioerp.com/community/developer/views-requests/request-controller/

On a sidenote. If you are having a hard-time with the screen definitions in xml, there is also a CMS which you can use to override and generate each screen. It is also worth checking out as an alternative, if you decide to customize the screens.


#3

yes i was able to locate the screens. Also the tutorial gives example of screens only. i have tried to understand but can not get it. What if the type is request and value is json or any other. For example this one…

<request-map uri="getPaymentRunningTotal">
        <event type="service" invoke="getPaymentRunningTotal"/>
        <response name="success" type="request" value="json"/>
        <response name="error" type="request" value="json"/>
    </request-map>

and this one

<request-map uri="createInvoice">
    <security https="true" auth="true"/>
    <event type="service" invoke="createInvoice"/>
    <response name="success" type="request" value="editInvoice"/>
    <response name="error" type="view" value="newInvoice"/>
</request-map>

#4

The one you looked up is a “view”, and the type of the view is a “screen”. The definition of the view is in the same file.

We focused on the “screen” type for the documentation, because it is the most common type. In case of json (which is implemented as a special type of request), whatever is in the request response will be taken and turned into a map. So if you call a service in your event, you can simply use the json view to turn the outcome into a json map. Same applies for csv or other view types.

A response of type “request” is another request, so it will redirect to the next url.


#5

where do i exactly find the requested url files?


#6

I have to quote myself here:

You can see that the response for “success” is a “view” with name “findInvoices”. Check in the same file for a view-map of the same name.

So in other words, the “view-map” shows you the file.


#7

sorry for thes kind of questions, i do not have ofbiz background and i am coming from those direct mvc such as grails


#8

yeah, no problem, it is not different in other mvcs, except that there you are defining the responsed directly in code, whereas here you have definition files. Conceptually it is not different though. In grails you also have requests and responses and a definition of what the response should be.


#9

what i wanted to know is if the response for succes is a request which redirect to next url. where do i exactly find those files?(if response is not a view)


#10

A request is a request, so it will be another call to the controller and most likely be mapped against a request-map.

(We often use this to chain the user through an event flow)


#11
<handler name="service" type="request" class="org.ofbiz.webapp.event.ServiceEventHandler"/>

where do i find this
class="org.ofbiz.webapp.event.ServiceEventHandler


#12

Now i am in a ServiceEventHandler, but i can not see the method to invoke. I percieved that when i get the ServiceEventHandler i will see the method createPaymentAndFinaccountTrans. this is due to this part of a controller


#13

No, that is not how it works. Services are defined in service definition files and then called from any place in the system. The implementation is linked in the service definition. The process is described here:

https://www.scipioerp.com/community/developer/services/

So to summarize: your controller binds request events to trigger services or pieces of code, which then return a result. The result can then be mapped against a view or other request or such .


#14

but from the documentation it’s hard to locate the specific service called from the controller


#15

service folder has many subfolders and files


#16

There is a handy little overview available in your Backend. Log onto https://localhost:8443/admin and click on Service in the lefthand menu.


#17

thank you now i got there and i can see how things link. Another question, i can see in the screens of services these groovy ${} but not sure where they are come from.


#18

Are thes coming from the engine files called in service definition?


#19

Well, that’s a rather open question, but lemme try to explain:

Generally speaking all ${variables} are interpreted by the freemarker renderer. You can use them regardless of whether you write screens in the xml screen (form, menu etc) definition or in ftl with the templating toolkit, because we implemented the renderer in such a way that it uses the same logic underneath.

Now, the variables are there because they are in the “context”. You can put variables in context via groovy files that are being loaded during screen rendering, in the *widget definitions themselves (screens, forms, menus etc), events, services, via freemarker code or other means. There are various examples around for each type. To give you a few examples:

  1. In screen definitions you can use the <set name="" value="" notation. You can also include a groovy file to do things
  2. In groovy files you can use the context.variableName notation to add objects to the context map
  3. In screens you can also call entities or services. Those too will then be able to write to context (you have to specify the name to be used in context, though)
  4. In your controller request-maps you can call events or services, those will also be able to write to the context
  5. In freemarker you can set global variables
  6. In your theme you can define variables in groovy or custom templating toolkit macros, both will also be placed in context
    etc.

There are many more options and you can also use request parameters, request attributes, variables from application or system context, system properties and more…


#20

Your answers have been helpful, i have been able to understand some service engine especially those written in java. but those written in xml are kinda headache. what can i do to master? for example this means it is updating the database but can not see if it is really updating the database