andruhon commented on issue #402: WICKET-6731: Inline JS in SubmitLink
URL: https://github.com/apache/wicket/pull/402#issuecomment-579607334
 
 
   Sorry for late comment. What if we add something like these to avoid 
repeated use of Strings concatenation programming?
   
   ```
        public static void addEventListener(final IHeaderResponse 
headerResponse, Component component, String event, CharSequence javascript)
        {
                addEventListener(headerResponse, component, event, "event", 
javascript, false);
        }
   
        public static void addEventListener(final IHeaderResponse 
headerResponse, Component component, String event, String eventParamName, 
CharSequence javascript, boolean priority)
        {
                OnDomReadyHeaderItem item = OnDomReadyHeaderItem.forScript(
                                String.format(
                                                "var el = 
document.getElementById('%s'); if(el){el.addEventListener('%s', function(%s){ 
%s; });}",
                                                component.getMarkupId(),
                                                event,
                                                eventParamName,
                                                javascript
                                )
                );
                headerResponse.render(priority ? new PriorityHeaderItem(item) : 
item);
        }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to