Objectify Struts2 Tags

A Struts 2 tag that allows an iterator to be used to populate a grand-parent element.

Лицензия

Лицензия

Группа

Группа

be.objectify
Идентификатор

Идентификатор

objectify-struts2-tags
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Objectify Struts2 Tags
A Struts 2 tag that allows an iterator to be used to populate a grand-parent element.
Система контроля версий

Система контроля версий

https://github.com/schaloner/struts2-iterable-params

Скачать objectify-struts2-tags

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/be.objectify/objectify-struts2-tags/ -->
<dependency>
    <groupId>be.objectify</groupId>
    <artifactId>objectify-struts2-tags</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/be.objectify/objectify-struts2-tags/
implementation 'be.objectify:objectify-struts2-tags:1.0'
// https://jarcasting.com/artifacts/be.objectify/objectify-struts2-tags/
implementation ("be.objectify:objectify-struts2-tags:1.0")
'be.objectify:objectify-struts2-tags:jar:1.0'
<dependency org="be.objectify" name="objectify-struts2-tags" rev="1.0">
  <artifact name="objectify-struts2-tags" type="jar" />
</dependency>
@Grapes(
@Grab(group='be.objectify', module='objectify-struts2-tags', version='1.0')
)
libraryDependencies += "be.objectify" % "objectify-struts2-tags" % "1.0"
[be.objectify/objectify-struts2-tags "1.0"]

Зависимости

provided (2)

Идентификатор библиотеки Тип Версия
org.apache.struts : struts2-core jar 2.1.6
javax.servlet : jsp-api jar 2.0

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

From an old, old blog post on my blog

When building a Struts2 application recently, I needed to add arbitrary parameters to a URL when creating the menu from dynamic content. The parameters were stored in a map, so I used the my standard bit of code for iterating over a map:

<s:url var="url" action="%{link}" >
  <s:iterator value="parameters.keySet()" var="key">
    <s:param name="%{key}" value="%{parameters.get(#key)}"/>
  </s:iterator>
</s:url>

…and nothing happened. No parameters at all appeared in the URL.

Odd.

I got rid of the iterator and used a single parameter, just to check:

<s:url var="url" action="%{link}" >
  <s:param name="test-name" value="test-value"/>
</s:url>

That worked fine. One quick debugging session later and I found the problem – the Struts2 org.apache.struts2.components.Param component parameterises its parent component. In this case, the parent component is an iterator and so it was absorbing the parameters and they were never getting as far as the URL.

I couldn’t find a way to do what I needed the core Struts2 components and tags and so I created my own.

IterableParam overrides Param’s findAncestor method to return the grandparent component in the case where the parent is an Iterator:

<s:url var="url" action="%{link}" >
  <s:iterator value="parameters.keySet()" var="key">
    <ob:iterable-param name="%{key}" value="%{parameters.get(#key)}"/>
  </s:iterator>
</s:url>

Result – works as required.

Despite the title of this blog entry, any Struts2 component that can be parameterised using the <s:param> tag can be parameterised using ob:iterable-param.

Версии библиотеки

Версия
1.0