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

Specification missing list of retargetable handlers #922

Closed
eclipse-faces-bot opened this issue Jan 24, 2011 · 11 comments
Closed

Specification missing list of retargetable handlers #922

eclipse-faces-bot opened this issue Jan 24, 2011 · 11 comments

Comments

@eclipse-faces-bot
Copy link

There is no way to access retargetable handlers list in JSF. Mojarra uses 'javax.faces.RetargetableHandlers' attribute, while MyFaces has org.apache.myfaces.view.facelets.FaceletCompositionContext.getAttachedObjectHandlers(UIComponent) method. IMO, JSF specification should clarify this.

Affected Versions

[2.0]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by nick_belaevski

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
ppitonak said:
Hi, any updates on this issue?

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
File: 20120904-1737-i_spec_922.patch
Attached By: @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Marked as fixed on Tuesday, September 4th 2012, 6:47:12 pm

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
lu4242 said:
Checking the spec javadoc I notice the introduction of this constant:

AttachedObjectHandler.ATTACHED_OBJECT_HANDLERS_KEY

With this description:

"... The key in the value set of the composite component BeanDescriptor,
the value for which is a List. ..."

The spec issue is this:

http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-922

In few words, that constant does not have any sense and should be removed.
I suppose it try to do the same as
AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY, but after thinking a lot
about it these two are different cases.

The idea behind AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY is keep a
list of the "targets" or in other words the components and the behavior that
can be applied to those components. In that sense, there is one interface for
ActionSouce2, other for ClientBehavior and so on.

In order to be included in AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY
list, the implementations of AttachedObjectTarget are suppose to be
Serializable. Additionally, the definition of the targets is done when
vdl.getComponentMetadata() call is done, and that list does not change
across composite component instances of the same kind.

But AttachedObjectHandler.ATTACHED_OBJECT_HANDLERS_KEY is a complete
different story by these reasons:

  • First of all, the instances of AttachedObjectHandler are not
    Serializable, and it can't be because usually it refers to a some facelet
    TagHandler instance.
  • The idea behind UIComponent.BEANINFO_KEY or the composite component
    BeanDescriptor is that the information there is related to the composite
    component itself and not on the specific composite component instance.
    For example:

<myCCLib:customButton ...>
<f:actionListener for="buttonA" .../>
</myCCLib:customButton>

Generates a list of AttachedObjectHandler with the actionListener TagHandler.

<myCCLib:customButton ... />

Does not generate any list.

Ignoring the first reason, the right place to put this information is not
the composite component bean description, instead it is the composite
component attribute map.

  • The list of AttachedObjectHandler is only relevant when the composite
    component is being populated, specifically for this method in
    ViewDeclarationLanguage:

public void retargetAttachedObjects(FacesContext context,
UIComponent topLevelComponent, List handlers)

This method is just executed once, because you can't add a
AttachedObjectHandler to a composite component once is already populated.

The right thing to do is create a method in ViewDeclarationLanguage like this:

public void addAttachedObjectHandler(FacesContext context,
UIComponent compositeComponentParent, AttachedObjectHandler handler)

In this way you can do what #922 wants: allow create
a tag handler for AttachedObjectHandler instances like f:actionListener or
f:clientBehavior or whatever outside JSF implementation.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
tandraschko said:
Why is this closed as fixed? I can't find it in the Mojarra API wheter in the MyFaces API.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
This was marked closed because the action taken was based on Leonardo's comment on 2013-01-24:

In few words, that constant does not have any sense and should be removed.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
tandraschko said:
I'm don't know this area of JSF very good but removing the constant doesn't fix problem.
There is currently no way in the specs to add the AttachedObjectHandler to a CC.

You mentioned the AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY as answer to Cagatay's mail but thats not a solution for that.
AFAICS AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY can be used to check if events are defined in the CC.

In Mojarra a AttachedObjectHandler can be attached via:
cc.getAttributes("javax.faces.RetargetableHandlers").put(...);
in 2.2 you can do it via:
cc.getAttributes("javax.faces.view.AttachedObjectHandlers").put(...);

In MyFaces it can be done via:
org.apache.myfaces.view.facelets.FaceletCompositionContext.getCurrentInstance().addAttachedObjectHandler(cc, ...);

Leo's proposed solution to add
public void addAttachedObjectHandler(FacesContext context, UIComponent compositeComponentParent, AttachedObjectHandler handler)
to ViewDeclarationLanguage sounds like a good way.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
tandraschko said:
Created a new ticket here: https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1420
It's not required to fix it in this way discussed here, but providing an abstract base for implementing behaviors would be a more global solution which would probably solve this problem.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-922

@eclipse-faces-bot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant