Hi Shing.

Nice to see you getting into T5. ;-)

Not sure why your resources.renderInformalParameters(writer)
fails, but it's likely a clash with the RenderInformals mixin
in AbstractField. You should read the docs about rendering
multiple tags:
http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/org/apache/tapestry/corelib/mixins/RenderInformals.html

I can confirm that writing a tag in beginRender and closing it
in afterRender (without calling renderInformalParameters) works
fine with informals because of AbstractField's RenderInformals.

Also, you don't need to add @SupportsInformalParameters.

Cheers,
Nick.


Shing Hing Man wrote:
I have subclassed AbstractField  to make a colour
picker component,
which is essentially a read only text field with a
clickable  icon next to it.
The component is working, but it does not render the
informal parameters.
With

 <t:colorPicker   size="3" color="color" />

I expect the rendered text field to have  an attribute
of size="3".

The following is the code of my component.
Any assistance is appreciated!

Shing

@SupportsInformalParameters
public class ColorPicker extends AbstractField {
        //private String clientId;

        @Parameter(required = true, principal = true)
        private String color;

        @Inject
        private Request request;

        @Inject
        private ComponentResources resources;

        @Environmental
        private PageRenderSupport support;

        @Inject

@Path("classpath:/org/man/tapestry5/components/AnchorPosition.js")
        private Asset anchorScript;

        @Inject

@Path("classpath:/org/man/tapestry5/components/ColorPicker2.js")
        private Asset colorPicker2Script;

        @Inject

@Path("classpath:/org/man/tapestry5/components/PopupWindow.js")
        private Asset popupWindowScript;

        @Inject

@Path("classpath:/org/man/tapestry5/components/colorPicker.gif")
        private Asset icon;

        

        void beginRender(MarkupWriter writer) {
                
            String name=getElementName();
                
                String pickerName = name + "_pick";
                String pickerColor = name + "_color";

                // need to find out how to gte the form name
                String formName = "form";
                String targetField = "document." + formName + "." +
pickerColor;

                String color = getColor();
                if (color == null) {
                        color = "#FFFFFF"; // white
                }

                String style = "background:" + color + ";color:" +
color + ";";
                
                writer.element("input", "type", "text", "name",
pickerColor,
                                "onFocus", "blur()", "style", style, "value",
                                color);
                resources.renderInformalParameters(writer);
                
            writer.end(); // end of input
        

                writer.element("a", "href", "javascript:void(null)",
"name",
                                pickerName, "id", pickerName, "onclick",
"select_color("
                                                + targetField + "," + "'" + pickerName + 
"'" +
")");

        
                writer.element("img", "src", icon.toClientURL(),
"border", 0, "align",
                                "top");

                writer.end(); // end of <img>
                writer.end(); // end of <a>
                
                support.addScriptLink(anchorScript);
                support.addScriptLink(popupWindowScript);
                support.addScriptLink(colorPicker2Script);
                
        }


        public String getColor() {
                return color;
        }

        public void setColor(String color) {
                this.color = color;
        }


        @Override
        protected void processSubmission(FormSupport
formSupport, String elementName) {
                
                color = request.getParameter(elementName +
"_color");
        }

}

Home page : http://www.lombok.demon.co.uk/



___________________________________________________________ Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to