« Return to Thread: Problem with ui:repeat and own tag

Problem with ui:repeat and own tag

by Dominik Dorn :: Rate this Message:

Reply to Author | View in Thread

Hello!

I've created an own tag by creating a TagHandler and a Renderer.

The tag looks like <dc:userString userId="#{newsEntry.userId}" />
(being userId an integer).
When using it with normal bean properties, it works as expected.

However if I try to use it within a <ui:repeat var="message"
value="#{messages}">
being messages a list of Message-Objects it doesn't work anymore,
meaning that the el

#{message.sender} does get resolved inside <ui:outputText
value="#{message.sender}" /> or
even without a tag but not within  my tag <dc:userString
userId="#{message.sender}" />

[code]
/**
 * HTML-Representation of the UserString
 */
public final class UserStringTagHandler extends TagHandler {

        private final TagAttribute userId;

        public UserStringTagHandler(ComponentConfig config) {
                super(config);
                this.userId = this.getRequiredAttribute("userId");
        }


        @Override
        public void apply(FaceletContext faceletContext, UIComponent
parentUIComponent) throws IOException, FacesException,
FaceletException, ELException {

// some business logic here; creating the "uss" object
                                if (userId.isLiteral()) { //If this TagAttribute is literal (not
#{..} or ${..})
                                        us = uss.getUserString(Integer.parseInt(userId.getValue(faceletContext)));
                                } else {
                                        int userIdInt = -1;


                                        if (parentUIComponent instanceof UIRepeat) {


                                                                                                        userIdInt = Integer.parseInt( userId.getValue(faceletContext) );
userIdInt); // this works with a normal bean property, but not with ui:repeat!
                                        us = uss.getUserString(userIdInt);

                                }

                                output.setValue(us);

                        }
                        catch (NumberFormatException numberFormatException) {
                                throw new TagAttributeException(userId, "Invalid userId given or
string not castable to a valid number", numberFormatException);
                        }
                } else {
                        output.setValue(userId.getValue());
                        output.setValue("UserStringTagHandler: XXXX numbertest of <b>" +
userId.getValue() + "</b> XXXX "); // place Object UserString in here
                }
                parentUIComponent.getChildren().add(output);
        }
}
[/code]

Please someone give me a hint... I've spent > 20h on this issue already.

Thanks,
Dominik

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Problem with ui:repeat and own tag