Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

massAttribute for multiple attribute-value pairs #186

Closed
VsevolodGolovanov opened this issue Dec 4, 2015 · 5 comments
Closed

massAttribute for multiple attribute-value pairs #186

VsevolodGolovanov opened this issue Dec 4, 2015 · 5 comments

Comments

@VsevolodGolovanov
Copy link

Like in #10, I have a bunch of inputs, but they have multiple common attribute values. With the current o:massAttribute implementation setting them is quite ugly:

<o:massAttribute name="value" value="#{filter.value}" target="javax.faces.component.UIInput">
    <o:massAttribute name="required" value="#{filter.required}" target="javax.faces.component.UIInput">
        <o:massAttribute name="disabled" value="#{filter.readOnly}" target="javax.faces.component.UIInput">
            <...>
                <x:inputThis />
                <y:inputThat />
            </...>
        </o:massAttribute>
    </o:massAttribute>
</o:massAttribute>

The nesting seems superfluous, the target is duplicated. Instead there could be something like:

<o:massAttributes target="javax.faces.component.UIInput">
    <o:pair key="value" value="#{filter.value}" />
    <o:pair key="required" value="#{filter.required}" />
    <o:pair key="disabled" value="#{filter.readOnly}" />

    <...>
        <x:inputThis />
        <y:inputThat />
    </...>
</o:massAttributes>

Couldn't reuse f:attributes here, since massAttribute has no component. Maybe create a custom tag for passing attributes to tag handlers, but there is already o:tagAttribute, so that could be confusing.

@BalusC
Copy link
Member

BalusC commented Dec 4, 2015

Makes sense.

@arjantijms
Copy link
Member

Key/values can also be set using the map literal syntax from EL, if we accept Map as type.

@BalusC
Copy link
Member

BalusC commented Dec 7, 2015

It only requires EL 3.0.

@BalusC
Copy link
Member

BalusC commented May 22, 2017

As we're now on OmniFaces 3.0 which supports EL 3.0, I took a second look. Unfortunately, the map idea didn't work out very well. EL 3.0 API doesn't offer any way to break down the map values into fullworthy ValueExpression instances. Instead, it immediately evaluates those value expressions while <o:massAttribute> needs to set the ValueExpression in its original and unevaluated form into the component. Otherwise, this won't work for dynamic and writable properties.

@BalusC
Copy link
Member

BalusC commented Dec 20, 2022

Closing off because it's technically not possible.

@BalusC BalusC closed this as completed Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants