10.13. des Interface DynamicAttributes

Schauen wir uns an, wie DynamicAttributes in der Praxis aussieht. Zunächst muss unsere Tag-Handler-Klasse das Interface DynamicAttributes aus der JSP-API implementieren. Und dieses Interface verlangt, dass Sie die Methode setDynamicAttribute() implementieren. Diese Methode muss die AttributName/Wert-Paare speichern. Eine Hashmap ist die perfekte Datenstruktur zur Speicherung dieser Informationen:

package com.example.taglib; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.DynamicAttributes; import javax.servlet.jsp.tagext.SimpleTagSupport; ...

Get Servlets und JSPs™ von Kopf bis Fuß now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.