Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional query with multiple values #163

Open
d3ep4k opened this issue Sep 13, 2022 · 0 comments
Open

Conditional query with multiple values #163

d3ep4k opened this issue Sep 13, 2022 · 0 comments

Comments

@d3ep4k
Copy link
Contributor

d3ep4k commented Sep 13, 2022

https://stackoverflow.com/questions/1490139/evaluate-list-contains-string-in-jstl?noredirect=1&lq=1

<jsp:directive.include file="../fragments/mason-init.jspf"/>
<m:resource>
  <m:request method="GET" item="false">
    <c:if test="${mtgReq.params['authType'] eq 'normal'}">

      <sql:query var="user" dataSource="${datasource}">SELECT * FROM account WHERE email=?
           <sql:param value="${mtgReq.params['email']}"/>
       </sql:query>
       <c:set target="${output}" property="user" value="${pageScope['user']}"/>
    </c:if>
    <c:if test="${mtgReq.params['authType'] eq 'google'}">
      <sql:query var="googleUser" dataSource="${datasource}">SELECT * FROM account WHERE email=?
      <sql:param value="${mtgReq.params['email']}"/>
      </sql:query>
      <c:set target="${output}" property="googleUser" value="${pageScope['googleUser']}"/>
    </c:if>
</m:request>
</m:resource>

Instead of above it should be

<jsp:directive.include file="../fragments/mason-init.jspf"/>
<m:resource>
  <m:request method="GET" item="false">
    <c:if test="${m:listContains(m:list("google","facebook", "twitter","linkedin"), mtgReq.params['authType'])}">
      <sql:query var="googleUser" dataSource="${datasource}">SELECT * FROM account WHERE email=?
      <sql:param value="${mtgReq.params['email']}"/>
      </sql:query>
      <c:set target="${output}" property="user" value="${pageScope['user']}"/>
    </c:if>
</m:request>
</m:resource>

The existing function jstl can be copied and new functions can be created under the same tld
https://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fn/tld-summary.html

With the issue fixes, it can be released as mason 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant