java - How to convert piece of JSP to the Thymeleaf syntax? -


I have some JSP, I want to convert to MyMelf:

  & lt ; C: Each variable = "portfoliowork" item = "$ {portfolio works}" varStatus = "statusVariable" & gt; & Lt; C: set var = "stylesStr" value = "" /> & Lt; C: If test = "$ {blank portfolio work .getPublicSitePortfolioWorksToTypeRelations ()}" & gt; & Lt; C: forEach var = "wRels" item = "$ {portfolioWork.getPublicSitePortfolioWorksToTypeRelations ()}" & gt; & Lt; C: set var = "stylesStr" value = "$ {stylesStr} type $ {wRels.getPublicSitePortfolioWorkTypes (). GetId ()}" /> & Lt; / C: foreach & gt; & Lt; / C: If & gt; & Lt; Div class = "element $ {stylesStr} block" & gt; * ******************************************** I do not understand how to change this complex structure:  
  & lt; C: set var = "stylesStr" value = "" /> & Lt; C: If test = "$ {blank portfolio work .getPublicSitePortfolioWorksToTypeRelations ()}" & gt; & Lt; C: forEach var = "wRels" item = "$ {portfolioWork.getPublicSitePortfolioWorksToTypeRelations ()}" & gt; & Lt; C: set var = "stylesStr" value = "$ {stylesStr} type $ {wRels.getPublicSitePortfolioWorkTypes (). GetId ()}" /> & Lt; / C: foreach & gt; & Lt; / C: If & gt;  

From my point of view, the best way to implement it is to make a custom AttrProcessor which If a class attribute value is set based on the "portfolioWorks" variable, then it will look like this:

  & lt; Div class = "element block" some_scope: appendClass = "$ {portfolioWorks}" & gt; & Lt; / Div & gt; Take a look at  


:

I also recommend watching through Thimlef sources, there are lots of atrire processors, so you can To get this idea to be faster.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -