Add Pretty-Link dynamically

Splash Forums PrettyFaces Users Add Pretty-Link dynamically

This topic contains 1 reply, has 1 voice, and was last updated by  atyauristen 6 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17820

    atyauristen
    Participant

    Hey there,

    I’m new to pretty faces and I have a question for you.

    Is there a way to add a pretty-link programmatically?

    What I wanna do is:

    UIComponent myLink = (Link)context.getApplication().createComponent(Link.COMPONENT_TYPE);

    myLink.setMappingId(“userHome”);

    //OR!

    myLink.getAttributes().put(“mappingId”, “userHome”);

    myLink.setStyleClass(“sc”);

    HtmlOutputText userName = new HtmlOutputText();

    userName.setValue(activa.getDisplayName());

    UIParameter id = new UIParameter();

    id.setName(USER_ID);

    id.setValue(activa.getId());

    myLink .getChildren().add(id);

    myLink .getChildren().add(userName);

    This code won’t work of course and I didn’t find any help for how to do this in the documentation.

    So I’d be very grateful if someone could help me!

    Thanks in advance!

    Balázs

    #20419

    atyauristen
    Participant

    why to ask if you know the answer? so here’s what I did:

    UIComponent commenterLink = (Link)context.getApplication().createComponent(Link.COMPONENT_TYPE);

    commenterLink.getAttributes().put(“mappingId”, “otherUserHomeTest”);

    commenterLink.getAttributes().put(“styleClass”, COMMENTER_STYLECLASS);

    HtmlOutputText userName = new HtmlOutputText();

    userName.setValue(activa.getDisplayName());

    UIParameter id = new UIParameter();

    id.setValue(activa.getId());

    commenterLink.getChildren().add(id);

    commenterLink.getChildren().add(userName);

    return commenterLink;

    First I set the name of the UIParam as well, then after some time I realised that this is the one that causes com.ocpsoft.pretty.PrettyException: Invalid number of parameters supplied for pattern exception to be thrown. Now I see the difference between setting it or not in the documentation but I’m not sure that the text of the exception is enough to realise that :S So it would be nice to have a more precise exception if possible.

    cheers,

    balázs

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.