question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EL function closestWidgetVar

See original GitHub issue

Currently you have an EL method resolveWidgetVar(String expression, UIComponent source) to find a widget var. I would like to have a method to find the widget var relative to the current component, so go up to the root until a component which implements Widget is found.

I created this method in my project:

  public static String closestWidgetVar() {
    return Stream.iterate(Components.getCurrentComponent().getParent(),
                          c -> Objects.nonNull(c.getParent()),
                          UIComponent::getParent)
            .filter(Widget.class::isInstance)
            .findFirst()
            .map(Widget.class::cast)
            .map(Widget::resolveWidgetVar)
            .map(w -> String.format("PF('%s')", w))
            .orElse(null);
  }

It uses Java 9 and OmniFaces, so it needs a bit of rewriting. If you want to I can create a PR for this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tandraschkocommented, Aug 18, 2020

and also introduce closestWidget, which can be reused by closestWidgetVar

0reactions
tandraschkocommented, Aug 19, 2020

Thanks for the PR!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to find a widgetVar? - Stack Overflow
So, what i am trying to do, is to call the close() method of the selectOneMenu widget var of that previously focused component....
Read more >
PrimeFaces JavaScript API Docs
A callback function for a behavior of a widget. ... Only the two properties id and widgetVar are guaranteed to be always ......
Read more >
USER GUIDE 5.2 - PrimeFaces
widgetVar null. String. Name of the client side widget. value null. Object. Value of the component than can be either an EL expression...
Read more >
JavaScript web_editor widget.Dialog Examples
Class.extend({ saveElement: function ($el, context) { // remove multi edition var ... Dialog'); var weWidgets = require('web_editor.widget'); var options ...
Read more >
Intro To PrimeFaces widgetVar - Hatem Alimam
The basics of debugging and knowing what to call and what this function would do is very simple and hard in the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found