Archive
Highlighted

help extending SimpleResultsTable

Path Finder

So I'm looking to add live URL links to SimpleResultsTable, and I've decided that the right place to do it is around line 230 or so in the code:

         elif fieldValues:
            renderedValues = [cgi.escape(x.value) for x in fieldValues[:MAX_MULTI_VALUE_COUNT]]
            if len(fieldValues) > MAX_MULTI_VALUE_COUNT:
                clipCount = len(fieldValues) - MAX_MULTI_VALUE_COUNT
                renderedValues.append(_('[and %d more values]') % clipCount)

            # when we have multiValued fields we wrap them each in its own div elements
            if (len(renderedValues) > 1) :
                multiValueStr = [MULTI_VALUE_WRAPPER % x for x in renderedValues]
                output.append('>%s</td>' % "".join(multiValueStr))
            # however for single values the extra div is unwanted.
            else :
                output.append('>%s</td>' % "".join(renderedValues))

My question is that since SimpleResultsTable only has one method, do I get any value of extending it verses just copying it to a new class and just extending AbstractPagedModule? Will the new class (call it URLResultsTable) pick up the SimpleResultsTable js and css files via inheritence from URLResultsTable.conf?

Also, feel free to include an RTFM link. I haven't been able to find much so far.

BTW: If I just embedded HTML in my data feed, would it get filtered out? I sort of hope so for security reasons...

Tags (1)
0 Karma
Highlighted

Re: help extending SimpleResultsTable

SplunkTrust
SplunkTrust

Because of some bugs, it depends where you're putting the JS for your custom module.

1) If you're putting them in /share/splunk/search_mrsparkle/modules, and you're going through the pain of keeping them there through upgrades, then you can do whatever you'd like and subclassing SimpleResultsTable is a good way to go.

2) If you're wanting to make a custom module in your app,

a) custom modules packaged in apps dont work in 4.1.5 (fix coming 4.1.6)

b) custom modules packaged in apps do not follow the inheritance chain which means more often than not that the files will get loaded in the wrong order and it wont work. Upshot is that you have to inherit directly from AbstractModule or DispatchingModule which is lame. I sent in a support case but I dont think anything's happened with it.

3) And if you're wanting to just put some code in etc//appserver/static/application.js, it's possible to kind of subclass SimpleResultsTable from itself... Download the discover app from splunkbase and take a look at its application.js. There are numerous examples where I had to patch certain methods in certain modules, on certain views.

Given the problems of #1 and #2, and for your circumstances, I recommend #3.

And if you need to have several SimpleResultsTables on the page and you only want to muck with one of them, that can be done too. Discover shows a lot of examples of completely clobbering a particular method. And if you want to still refer to $super() with this method that can be done too and I can give you an example. This seems like a long answer so I'll stop but email me if you want to know even more.

Highlighted

Re: help extending SimpleResultsTable

Path Finder
0 Karma