Is it possible to create something like rewrite rules in Boomla? For example, configure that a URL
//example.com/search-result/asdf
be handled by a given app, whether or not a file with this URL exists. I.e. to treat this URL as if it was something like
//example.com/search-result?q=asdf
If not, is it planned?
Planned but not possible right now (2017-05-15).
As planned, you will not be able to have custom rewrite rules that takes precedent over the filesystem. There will be some kind of a .RequestNotFound interface or similar for specifying such behavior. The event will bubble up along the filesystem tree and the first file to implement the interface will handle it.
Related
I have a lookup table called BlockCustomer. I also have an FTP Adapter that picks up files from multiple customers. I need to be able to determine the customer from the source of the file and do a lookup on the table. If BlockCustomer.Customer1 = 0 then it will send it to it's target, otherwise it will do nothing.
If I could use javascript I would do something like this:
WHEN Lookup(BlockCustomer,HL7.Source.split("/incoming/")[1].split("/")[0]),1) = 0
But obviously I can't. I found $ZSTRIP but I'm not sure if or how it will work. Is this possible or am I going to have to create a custom class?
In Cache we use function $piece if needs to get some parts of string by delimiter. For rule you could use the same function called Piece, with the same arguments. So you conditions should looks like:
Lookup(BlockCustomer,Piece(HL7.Source,"/incoming/",2),1)=0
By the way if you think, that you need some specific functions for you, you can do it by developing it. Just extend the class Ens.Rule.FunctionSet and add a method. And function will appear with the same name. As an example you can see at Ens.Util.FunctionSet class, which contains almost all available functions.
Since there seem to be no methods for input validation in JavaFX, I was thinking about how to do it in a clean way in my current project.
Here is my idea:
All validation rules are regular expressions (like "min-length", "not-empty", "only-numbers", etc), which are stored in a .properties file
Example: validationrules_only_numbers="[0-9]+"
I use this validations in the .fxml file by defining the <properties> tag for any input that should be validated
Example:
<ChoiceBox><properties rules="%validationrules_only_numbers"/></ChoiceBox>
In an abstract/parent controller I write a method which gets all children of the current AnchorPane and iterates over them (lets say after the user clicks OK to submit the form). All children which have validation rules are them passed to another method, which depending on the Type of the inputfield applies the validation rules to the input.
All controls with validation errors then get highlighted.
What I personally like about this idea:
the validation rules are easily expandable by just adding them to the .properties file
the rules are assigned in the .fxml file
all the controllers (which extend the abstract/parent controller) dont need to perform any validation tasks
What I dont like/am unsure if it works good in reality:
the validation rules are all regular expressions, I don't know if that works well with all the input fields (but I don't mind coding "hacks" to make it work, since I would do it only one time in a parent controller)
I must check the controls with instanceof to apply the rule correctly for this specific control, since not all controls have a getText() method and the input needs to be validated in other ways
don't know if there is a better way to put the rules in the .fxml file then using <properties>
What are your thoughts? Is there anything important I am missing here?
I was googling about this topic for several days and there seems to be no really good solution like those we are familiar with from the web development community.
Before you re-invent the wheel you might want to have a look at the validation framework contained in the ControlsFX package. Maybe you can combine that with your ideas.
I've been trying to implement a Front Controller on a VBScript (ASP Classic) based system for a couple of days. I come from a ASP.NET MVC and Java background, where MVC implementations are kind common and mostly done by existing frameworks. On VBScript, however, there's almost nothing done in this area, so it is the reason why I'm trying to do it by myself. I used this and this article as a guide on how to implement it.
I believed at first that I'd need to define some constant parameters for each request, so I created 3:
class_command 'which command responsible to execute the correct class handler
action 'which method of the class handler to execute
action_params 'which parameters the action will need
Next, I defined a generic controller handler for treating the request:
Public Function Controller_Handler(action_params)
Its task is to extract the constant parameters (class_command, action, action_params) and treat any errors (I'll add later a filter to process it) that might come like absence of the constant parameters or authentication problems.
But soon I realized a problem: how will the handler know which command to call, since the request is a string? I can't simply converting it to class using reflection, because VBScript (I think) doesn't have a reflection library or built-in feature.
So I thought I could create a Switch Case like this:
Select action_Params.Item("action_params")
Case "command_A"
' Call Command A
Case "command_B"
' Call Command_B
.
.
.
Case "Command_X"
' And so on
End Select
But that would kinda procedural way to do it. Next I thought of creating a XML file which would map all the commands and other stuff.
So my question is: is this a good way of implementing a Front Controlller pattern, considering VBScript limitations? If not, could you provide a guidance (hopefully with some example, even a simple one) on how can I do it?
Moving from classic to .net/mvc I can share what I did in classic asp to try to emulate this behavior as closely as possible without making it too much of a maintenance issue.
Using URL Rewrite in IIS are my routes. I usually just make one route and direct/rewrite all inbound requests to one controller.asp page to simplify things and not have a bunch of rules and controller redirects directly in my URL Rewrite settings for maintaining it easier (for me).
Using Request.ServerVariables("HTTP_X-ORIGINAL-URL") in controllers.asp you can grab the actual URL that was entered, which return something like.. /real/url
In controllers.asp programatically call the view based on the entered url using Server.Execute("view1.asp")
I have one class file called routes.asp that is included in each model/class file, and helps me gather the URL properties oRoute.GetPath_FirstDirectory() and so on. The model/class file then uses this data to create its property values that can be consumed by the view. Using CLASS_INITIALIZE in each model/class to populate itself from the route/url, or it could also be done directly in the view.
In the respective view I include my class/model file (if even needed) using <!--#include file="class.asp"--> then simply open Set Model = new cModelClass to initialize and start using it in the view. I don't include the class in the controllers.asp because the view will not inherit any of the variables from controllers.asp when using Server.Execute() to the view. So I include it directly in the view.
Error handling can be at multiple levels here, but ideally its in the controllers.asp. Specific error handling is usually at the actual model/class CLASS_INITIALIZE to avoid redundant use of the class in the controller, since it's already going to be initialized in the view.
Now this is not exactly what goes in in .Net mvc, but it's the best way I've come up with, and easiest to maintain for me. Maybe others have other implementations, but this is mine and solely based on my experience. And so far, it's been working out pretty well.
When using route names, for example with Url.RouteUrl, is there any mechanism that checks for the existence of a route during compile-time rather than stumbling across it during run-time?
It seems like changing a route name can be quite scary in a large project.
Absolutely, some smart new routing rules could take over routes you don't want them to.
I'd, and many others, would recommend unit tests for your routes in both directions. That is, verify the correct url will go to the expected action and your url creation gives the urls you want.
For a head start have a look at the mvcontrib test helpers for routes.
The idea of the desired filter is to check the memcached for page content with url as a key and if found, return it to client directly from cache and skip the controller altogether. Storing would be done in separate filter, which is the easy part. I'm aware i could write it to action's preExecute() but filters would offer more elegant solution (could turn them off for dev envs).
In other words - is there a smart way for a filter to push the response to client and skip going to action?
Implementing such a filter is quite easy. Actually similar solution exists in symfony.
Look at the default caching filter (sfCacheFilter class). It's doing something similar to what you're looking for.
Alternative path
It is already possible to use memcache directly by changing the default file caching to memcache.
In your factories file you're able to switch cache driver (apps/yourapp/config/factories.yml or config/factories.yml):
all:
view_cache:
class: sfMemcacheCache
You could do the same with memcached but as symfony doesn't provide sfMemcachedCache class you would have to implement it on your own.
This way you could reuse existing caching framework and take advantage of cache.yml files.
I would suggest you have a look at overwriting the sfExecutionFilter.
It's the last filter in the default filters.yml, which means it's the first executed.
This is what is responsible for calling your action's executeXXX method and loading associated view and bunch of other things.
Presumably you could write your own filter the extends sfExecutionFilter and overwrite it's functionality to skip executing the controller it the output is cached.
You can find the default filters.yml # %SYMFONY_DIR%/config/config/filters.yml