dev@javaserverfaces.java.net

Re: issue 1826

From: Sheetal Vartak <sheetal.vartak_at_oracle.com>
Date: Tue, 12 Oct 2010 10:51:58 -0700

Hi Ed,

Comments inline...
>
>
> You have hit upon a problem in the Java programming language that is
> solved by Project Jigsaw. Without Jigsaw, the only way to share a class
> among modules is to make it public. StateHolderSaver is an
> implementation specific class, but there is no way to have one
> implementation of that class be accessible in both jsf-api.jar and
> jsf-impl.jar. Our solution is to have two package private classes with
> the same code: com.sun.faces.application.view.StateHolderSaver and
> javax.faces.component.StateHolderSaver.
>
> I think the right thing to do is to fix issue [Mojarra-924-SingleJar]
> [1]. If we did this, then code in jsf-api could access com.sun.faces
> classes directly. Then, we could do away with having multiple copies of
> the same code in different packages. Note that StateHolderSaver is not
> the only case where we resort to this terrible hack.

Can we have something like the following :
specify an interface for StateHolderSaver in jsf-api. Have multiple implementations as required.
This way, in UIOutput or other components, one can check if the instance is an impl of the interface of StateHolderSaver. If so, work on that instance accordingly.
Would this require a spec change?

How will having both artifacts jsf-api and jsf-impl clubbed into one solve the problem? It does not seem like a good idea to directly access the com.sun.faces classes from jsf-api classes. Should'nt the API and impl remain separate? Or am I missing the point?

>
> SV> I see that code was introduced in
> SV> StateManagementStrategyImpl.saveComponentState() as follows :
>
> SV> if (stateContext.componentAddedDynamically(c)) {
> SV> stateObj = new StateHolderSaver(ctx, c); //This is com.sun.faces.application.view.StateHolderSaver
> SV> // ensure it's in the addList.
> SV> Map<String, ComponentStruct> dynamicAdds = stateContext.getDynamicAdds();
> SV> assert(null != dynamicAdds);
> SV> String clientId = c.getClientId(ctx);
> SV> if (!dynamicAdds.containsKey(clientId)) {
> SV> ComponentStruct toAdd = new ComponentStruct();
> SV> toAdd.absorbComponent(ctx, c);
> SV> dynamicAdds.put(clientId, toAdd);
> SV> }
> SV> } else {... }
>
> SV> But there is no code to restore state if the stateObj is of type
> SV> com.sun.faces.application.view.StateHolderSaver.
>
> Please correct me if I'm wrong, but it looks like that code is on line
> 312 of StateManagementStrategyImpl.java.

Its line 370 onwards in StateManagementStrategyImpl.java.

Thanks
Sheetal

>
> Ed
>
> [1] https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=924
>
> --
> | ed.burns_at_sun.com | office: +1 407 458 0017
> | homepage: | http://ridingthecrest.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net