Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Struts - logic:iterate - Farbwechsel in Tabelle

Empfohlene Antworten

Veröffentlicht

Hi,

und wieder mal eine Struts Frage!

Ich habe eine Tabelle die über ein logic:iterate aufgebaut wird.

Es soll jetzt jede Zeile abwechselnd eine andere Hintergrundfarbe zugewiesen werden über "class="bg01" bzw "class=bg02".

<logic:iterate id="mail" property="mails" name="InboxForm" type="DTONachricht" indexId="i">
<tr valign="top" class="bg01">
...
[/PHP]

Weiss jmd ob ich jetzt über das indexId="i" irgendwie die "bg01" austauschen kann?

Kann ich das über ne Berechnung machen in nem logic-tag???

Gruss

Jo

Nein,

nur über ein Scriptlet.

<%= i%2==0?"class1":"class2" %>

ungetestet!

Oder du schreibst dir einen eigenen iterate tag.

In dem Buch ist ein Beispiel:

http://www.javashelf.com/book/1932394249.html

Gruß Jaraz

  • Autor

Es funktioniert folgendermaßen:


//Hintergrundklasse tauschen:
<tr valign='top' class=
<%= (Integer.valueOf(i.toString()).intValue())%2==0?"bg01":"bg02" %>>

[/PHP]

Also so wie du gesagt hast Jaraz, mit einer kleinen Erweiterung. ;)

Dank dir, mal wieder.

Mit dem tag umschreiben mach ich mal an einem langweiligen Sonntag Nachmittag! :D

noch einfacher:

du iterierst ja wahrscheinlich ueber alle zeilen der tabelle.

wenn Du die jstl verwendest, dann via <c:forEach

diueser tag hat ein attribut varStatus...

den verwendest Du und fragst ihn ab via <c:if

gruss

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.