<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jirat Chaipacharaporn on Medium]]></title>
        <description><![CDATA[Stories by Jirat Chaipacharaporn on Medium]]></description>
        <link>https://medium.com/@jirat.c?source=rss-577c552f1a09------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Jirat Chaipacharaporn on Medium</title>
            <link>https://medium.com/@jirat.c?source=rss-577c552f1a09------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 10:34:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jirat.c/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Basic Struts2 migration in a nutshell for beginner]]></title>
            <link>https://medium.com/@jirat.c/basic-struts2-migration-in-a-nutshell-for-beginner-b31fd8b452c0?source=rss-577c552f1a09------2</link>
            <guid isPermaLink="false">https://medium.com/p/b31fd8b452c0</guid>
            <dc:creator><![CDATA[Jirat Chaipacharaporn]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 04:11:30 GMT</pubDate>
            <atom:updated>2023-10-27T04:11:30.181Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*M4VlNiio3nKWRhP4cYlpVg@2x.jpeg" /></figure><p>Apache Struts framework is an open-source web application framework from Apache Software Foundation. Its first release was in May 2000 and is still available nowadays with Struts2. So, This proves the framework itself that this is a good framework among popular web application frameworks such as React or Spring. So let’s talking about migration.</p><p>Ps. This article is base on Struts2 version 6.3.0.1</p><h3>PART I struts configuration file</h3><p>The first change in struts-config.xml is its name. The Struts1 configuration file has changed its name to struts.xml and changed its stored location from the WEB-INF folder to the project source folder.</p><p>Inside struts configuration file has many changes. The first thing you need to change when migrating to struts2 is replacing the DOCTYPE tag with this code.</p><pre>&lt;!DOCTYPE struts PUBLIC<br>      “-//Apache Software Foundation//DTD Struts configuration 6.0//EN”<br>      “https://struts.apache.org/dtds/struts-6.0.dtd”&gt;</pre><p>At the top level of the configuration file, The &lt;struts-config&gt; tag has been changed to &lt;struts&gt;.</p><p><strong>Exception handling section</strong></p><p>In Struts1 we use &lt;global-forward&gt; to forward the user globally to the destination page, But in Struts2 we use &lt;global-result&gt; instead and all &lt;forward&gt; tag has been changed to &lt;result&gt; tag</p><pre>&lt;global-result&gt;<br>   &lt;result name=”yourResultName”&gt;<br>      &lt;param name=”actionName”&gt;yourActionName&lt;/param&gt;<br>   &lt;/result&gt;<br>&lt;/global-result&gt;<br><br>&lt;global-exception-mapping&gt;<br>   &lt;exception-mapping exception=”yourException” result=”yourResultName” /&gt;<br>&lt;/global-exception-mapping&gt;<br><br>&lt;action name=”yourActionName”&gt;<br>   &lt;result name=”yourResultName”&gt; do something &lt;/result&gt;<br>&lt;/action&gt;</pre><p>How it work? Global Exception Mapping caught specific exception you defying and then go to Global Result to find what action mapping result name with. At the end your result name in action will tell your program what to do.</p><p><strong>Action mapping section</strong></p><p>The concept of Action mapping was changed to package. This was Action Mapping look in Strust2.</p><pre>&lt;package name=”default” extend=”struts-default”&gt;<br>   &lt;action name=”yourActionName” class=”yourActionClass”&gt;<br>      &lt;result name=”yourResultName”&gt; do something &lt;/result&gt;<br>   &lt;/action&gt;<br>&lt;/package&gt;</pre><h3>PART II Java file</h3><p>There is some change in Java file such as Action, ActionForm and etc.</p><p><strong>ActionForward</strong></p><p>In Struts2, there is no ActionForward to return forward mapping anymore. Instead, you can return String which will map with Result under Action tag in struts.xml</p><p><strong>Action Class</strong></p><p>In Struts1, We have to extend the action class with “org.apache.struts.action.Action”, but in Struts2 framework we extend the action class with “com.opensymphony.xwork2.ActionSupport” instead.</p><pre>import com.opensymphony.xwork2.ActionSupport;<br><br>public class yourClass extends ActionSupport {<br><br>   public String execute() {<br><br>      //do something<br><br>      return “yourResult”;<br><br>   }<br><br>}</pre><h3>PART III JSP file</h3><p>There were a few changes in JSP file such as tag and import name.</p><p><strong>Import name</strong></p><p>In Struts1, we have to import Bean, Logic, html etc from file XX-struts.ltd. But in Struts2, you only need to add one import to your JSP file.</p><pre>&lt;% taglib prefix=”s” uri=”/struts-tags” %&gt;</pre><p><strong>The data tag (bean, jsp, logic, html)</strong></p><p>These above tags are from struts1, In Struts2 we use these codes instead, here an example.</p><p>bean:message</p><pre>&lt;s:text /&gt;</pre><p>html:form</p><pre>&lt;s:form /&gt;</pre><p>jsp:include</p><pre>&lt;s:include /&gt;</pre><p>logic:notEmpty</p><pre>&lt;s:if test=”yourVar != null”&gt;<br>   inside logic code<br>&lt;/s:if&gt;</pre><p>For more information, please read the document. If I give the wrong information in this article, I apologize in advance.</p><p><strong>Some useful reference</strong></p><ul><li><a href="https://www.tutorialspoint.com/struts_2/struts_data_tags.htm">Struts 2 - Data Tags</a></li><li><a href="https://struts.apache.org/tag-developers/tag-reference.html">Tag Reference</a></li><li><a href="https://struts.apache.org/maven/struts2-core/apidocs/index.html">Struts 2 Core 6.3.0 API</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b31fd8b452c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple filter/sort item list from Firebase in Flutter application]]></title>
            <link>https://medium.com/@jirat.c/simple-filter-sort-item-list-from-firebase-in-flutter-application-59b17b467a0a?source=rss-577c552f1a09------2</link>
            <guid isPermaLink="false">https://medium.com/p/59b17b467a0a</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[application-development]]></category>
            <dc:creator><![CDATA[Jirat Chaipacharaporn]]></dc:creator>
            <pubDate>Thu, 08 Jun 2023 08:37:58 GMT</pubDate>
            <atom:updated>2023-06-08T08:37:58.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kv8sUyE94iDCqQjRzaG8MQ.png" /></figure><p>Have a problem filtering or sorting items which query from <strong>Firebase Firestore</strong>? I have a simple idea for you to get started. But before we start, There is some function you need to know.</p><p>This tutorial consists of the following functions:<strong> data retrieving function</strong>, <strong>filtering function</strong> and <strong>sorting function</strong> (optional). Filter and sort menu create separate from the main screen as you can see in <strong>Figure 1</strong> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WVx80DPB0NVyiVTv2OMe5w.jpeg" /><figcaption>Figure 1 : The actual look of filter/sort page implement in this tutorial</figcaption></figure><p>The idea of filtering is to query first and filter after that. First, create a function to retrieve data from Firestore(database). For example, my project uses Streambuilder to retrieve data from Firestore because we want to query data in real time.</p><pre>someGlobalVar = true ;<br><br>//UI section<br>Scaffold(<br>  Body(<br>    <strong>getDataList()</strong><br>  ),<br>);</pre><pre>getDataList() {<br>  //set sort value from user select<br>  setSortOption(){<br>    setstate(someGlobalVar = fromUserSelect);<br>  }<br>  <br>  //can be replace by other way of query    <br>  return streambuilder(<br>  stream : someQueryCode(orderBy(someGlobalVar)),<br>  builder : () {<br>    <br>    //Data from (query) stream<br>    if(filter(Data)) {<br>      return someUiCode(data); //Data pass filter<br>    }else{<br>      return const SizedBox(); //Data doesn&#39;t pass filter<br>    }  <br>  }<br>  );<br>}</pre><p>Second, create a filtering function with one or more filtering if-else logic whatever you want inside. Create a variable (global) for your filtering logic. In each filtering, there is a difference in the result calculation. For example, my project has status and individual filtering, such as room and floor filtering.</p><p><strong>For status filtering</strong>, the result will calculate by using the <strong>OR</strong> operation on all of the status’s if-else logic results. We use OR operation because we want data to come out whether the data matches one or more logic.</p><p><strong>For individual filtering</strong>, the result will calculate by using the <strong>AND</strong> operation on all of the individual’s if-else logic results. We use AND operation because we want data to come out only to match one specific logic.</p><p>The final result will calculate by using <strong>AND</strong> operation on these two results from the previous section and use this result to consider if data should show on the output or not.</p><pre>//Filtering Function Example<br><br>filter(someobject Data){<br>  if (data[&#39;query&#39;] == &#39;due date&#39;) {<br>     sortOption = &#39;due date&#39;;<br>     if (data[&#39;isDescending&#39;]) {<br>       //true<br>       _selectedSortType = sortType.oldest;<br>       isDescending = true;<br>     } else {<br>        //false<br>        _selectedSortType = sortType.newest;<br>        isDescending = false;<br>      }<br>   }<br>   ...(can be more than one filter)<br>   return final_result_from_calculation;<br>}</pre><p>Then, place the filtering function inside the builder block of Streambuilder(). In addition, you can count the number of lists that came out from the filtering process and use it for displaying if a list didn’t come out from filtering even a single one, your application must show something else instead, Such as “no data match with selected filter”.</p><p>For <strong>sorting data</strong>, I mainly use <strong>Indexes</strong> in Cloud Firestore. Thus, you need to set up field indexes, which need to be sorted, in your Firebase project before starting. For more information please read <a href="https://firebase.google.com/docs/firestore/query-data/indexing">this document</a>.</p><p>Create a sorting function and a global variable. We create a sorting function to save the user-selected sort options from the sort menu and sending sorting option between page resulting in the selected sort option not refreshing while switching between the sort menu and the main screen (you can do the same thing with filtering to save the selected filter option). Use those sort value from global variable to sort data through query.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59b17b467a0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>