https://issues.apache.org/jira/browse/MYFACES-2469
On Wed, Dec 30, 2009 at 6:38 PM, Matthias Wessendorf <[email protected]> wrote: > swapped in the RI; > > It just renders this as text (instead of a link) > > <h:link outcome="invalidOutcome">Blah Foo Bar </h:link> > > => <span>Blah Foo Bar</span> > > This does not sound wrong :-) > > .Matthias > > On Wed, Dec 30, 2009 at 6:30 PM, Matthias Wessendorf <[email protected]> > wrote: >> On Wed, Dec 30, 2009 at 6:26 PM, Matthias Wessendorf <[email protected]> >> wrote: >>> Hi Leo, >>> >>>> ============================================================================== >>>> --- >>>> myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java >>>> (original) >>>> +++ >>>> myfaces/shared/trunk_4.0.x/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java >>>> Thu Sep 10 15:51:44 2009 >>>> @@ -30,6 +30,10 @@ >>>> import org.apache.myfaces.shared.renderkit.html.util.JavascriptUtils; >>>> >>>> import javax.faces.FacesException; >>>> +import javax.faces.application.ConfigurableNavigationHandler; >>>> +import javax.faces.application.NavigationCase; >>>> +import javax.faces.application.NavigationHandler; >>>> +import javax.faces.application.ViewHandler; >>>> import javax.faces.component.*; >>>> import javax.faces.component.behavior.ClientBehavior; >>>> import javax.faces.component.behavior.ClientBehaviorHolder; >>>> @@ -1693,7 +1697,75 @@ >>>> return formInfo.getFormName() + NamingContainer.SEPARATOR_CHAR >>>> + HIDDEN_COMMANDLINK_FIELD_NAME_MYFACES_OLD; >>>> } >>>> + >>>> + public static String getOutcomeTargetLinkHref ( >>>> + FacesContext facesContext, UIOutcomeTarget component) throws >>>> IOException >>>> + { >>>> + String fragment = (String) component.getAttributes().get >>>> ("fragment"); >>>> + String href = component.getOutcome(); >>>> + ViewHandler viewHandler = >>>> facesContext.getApplication().getViewHandler(); >>>> + >>>> + // The href for an HtmlOutcomeTargetLink is outcome#fragment. >>>> + >>>> + href = ((href == null) ? "" : href.trim()); >>>> + >>>> + // Get the correct URL for the outcome. >>>> + >>>> + NavigationHandler nh = >>>> facesContext.getApplication().getNavigationHandler(); >>>> + if (!(nh instanceof ConfigurableNavigationHandler)) >>>> + { >>>> + throw new FacesException("navigation handler must be instance >>>> of ConfigurabeNavigationHandler for use h:link or h:button"); >>>> + } >>>> + ConfigurableNavigationHandler navigationHandler = >>>> (ConfigurableNavigationHandler) nh; >>>> + >>>> + //fromAction is null because there >>>> + NavigationCase navigationCase = >>>> navigationHandler.getNavigationCase(facesContext, null, href); >>>> + >>>> + href = navigationCase.getToViewId(facesContext); >>> >>> are you sure that "navigationCase" is never null here, in this case ? >> >> I have an <h:link outcome="foo"> where there is not foo.xhtml; >> >> -Matthias >> >>> >>> -Matthias >>> >>> >>> >>>> + >>>> + if (fragment != null) >>>> + { >>>> + fragment = fragment.trim(); >>>> + >>>> + if (fragment.length() > 0) >>>> + { >>>> + href += "#" + fragment; >>>> + } >>>> + } >>>> + >>>> + Map<String, List<String>> parameters = null; >>>> + >>>> + for (Iterator it = component.getChildren().iterator(); >>>> it.hasNext(); ) >>>> + { >>>> + UIComponent child = (UIComponent)it.next(); >>>> + if (child instanceof UIParameter) >>>> + { >>>> + String name = ((UIParameter)child).getName(); >>>> + Object value = ((UIParameter)child).getValue(); >>>> + if (parameters == null) >>>> + { >>>> + parameters = new HashMap<String,List<String>>(); >>>> + } >>>> + if (parameters.containsKey(name)) >>>> + { >>>> + parameters.get(name).add(value.toString()); >>>> + } >>>> + else >>>> + { >>>> + ArrayList<String> list = new ArrayList<String>(1); >>>> + list.add(value.toString()); >>>> + parameters.put(name, list); >>>> + } >>>> + } >>>> + } >>>> >>>> + // In theory the precedence order to deal with params is this: >>>> + // component parameters, navigation-case parameters, view >>>> parameters >>>> + // getBookmarkableURL deal with this details. >>>> + href = viewHandler.getBookmarkableURL(facesContext, href, >>>> parameters, component.isIncludeViewParams()); >>>> + >>>> + return href; >>>> + } >>>> >>>> private static String HTML_CONTENT_TYPE = "text/html"; >>>> private static String TEXT_ANY_CONTENT_TYPE = "text/*"; >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Matthias Wessendorf >>> >>> blog: http://matthiaswessendorf.wordpress.com/ >>> sessions: http://www.slideshare.net/mwessendorf >>> twitter: http://twitter.com/mwessendorf >>> >> >> >> >> -- >> Matthias Wessendorf >> >> blog: http://matthiaswessendorf.wordpress.com/ >> sessions: http://www.slideshare.net/mwessendorf >> twitter: http://twitter.com/mwessendorf >> > > > > -- > Matthias Wessendorf > > blog: http://matthiaswessendorf.wordpress.com/ > sessions: http://www.slideshare.net/mwessendorf > twitter: http://twitter.com/mwessendorf > -- Matthias Wessendorf blog: http://matthiaswessendorf.wordpress.com/ sessions: http://www.slideshare.net/mwessendorf twitter: http://twitter.com/mwessendorf
