Hi,

I would like to know if there is a better way to code this case : What
I would like to do is to enable/disable a link depending on a
condition. If the condition is true, than we create the link otherwise
we disable it. In both case, a label must be defined for the Link.

I mean, is it possible to avoid to double the creation of the link =
new Link() ....

Here is my code

1) HTML

           <a href="#" wicket:id="linkRequest"><span
wicket:id="linkRequestTxt"/></a>


2) JAVA

                // Set link for requestId
                Link link;

                if (audit.getRequest() != null) {

                    final RequestFormModel requestFormModel = new
RequestFormModel();
                    requestFormModel.setRequestId( (int)
audit.getRequest().getId() );

                    link = new Link("linkRequest") {

                        @Override
                        public void onClick() {
                            setResponsePage(new RequestPage(requestFormModel));
                        }

                    };

                    link.add(new
Label("linkRequestTxt",String.valueOf(audit.getRequest().getId())));
                    item.add(link);

                } else {
                    link = new Link("linkRequest") {

                        @Override
                        public void onClick() {
                            this.setEnabled(false);
                        }

                    };
                    Label label = new Label("linkRequestTxt","");
                    link.add(label);
                    item.add(link);


Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to